[infinispan-issues] [JBoss JIRA] Issue Comment Edited: (ISPN-1131) Locking optimization: acquire (write) locks at prepare time
Mircea Markus (JIRA)
jira-events at lists.jboss.org
Mon May 23 16:20:01 EDT 2011
[ https://issues.jboss.org/browse/ISPN-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603758#comment-12603758 ]
Mircea Markus edited comment on ISPN-1131 at 5/23/11 4:18 PM:
--------------------------------------------------------------
Suggested design.
On first release this is an experimental feature disabled by default.
In ordert to enable it use the following configuration element:
{code:xml}
<locking
isolationLevel="READ_COMMITTED"
lockAtPrepareTime="true" />
{code}
In order to preserve the existing functionality and also support *lockAtPrepareTime* a new interceptor is added: {{PrepareTimeLockingInterceptor}}:
* it extends {{LockingInterceptor}}
* when *lockAtPrepareTime* is enabled it takes {{LockingInterceptor}}'s place is the interceptor chain
* it overrides all {{LockingInterceptor}}'s {{visit<WriteCommand>}} methods (e.g. visitpPutKeyValueCommand) and does not acquire write locks on these invocations but read locks
* read locks are acquired similar to {{LockingInterceptor.visitGetKeyValueCommand()}}:
{code:java}
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable {
try {
entryFactory.wrapEntryForReading(ctx, command.getKey());
return invokeNextInterceptor(ctx, command);
} finally {
doAfterCall(ctx);
}
}
{code}
* {{PrepareTimeLockingInterceptor.visitPrepareCommand}} overrides {{LockingInterceptor.visitPrepareCommand}}:
{code:java}
@Override
public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command) throws Throwable {
super.visitPrepareCommand(ctx, command);
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
return invokeNextInterceptor(ctx, command);
}
{code}
* {{acquireLock()}} in the code above acquires locks *exactly* the same way {{LockingInterceptor}} would do for a given command.
** E.g. {{acquireLock(PutKeyValueCommand)}} is equivalent with {{LockingInterceptor.visitPutKeyValueCommand(..)}}
** if in distributed mode, the acquire lock *only* acquires a lock if the key(s) within {{WriteCommand}} map to the local node
** if lock cannot be acquired for a key all acquired locks are release and the transaction is marked for rollback
was (Author: mircea.markus):
Suggested design.
On first release this is an experimental feature disabled by default.
In ordert to enable it use the following configuration element:
{code:xml}
<locking
isolationLevel="READ_COMMITTED"
lockAtPrepareTime="true" />
{code}
In order to preserve the existing functionality and also support *lockAtPrepareTime* a new interceptor is added: {{PrepareTimeLockingInterceptor}}:
* it extends {{LockingInterceptor}}
* when *lockAtPrepareTime* is enabled it takes {{LockingInterceptor}}'s place is the interceptor chain
* it overrides all {{LockingInterceptor}}'s {{visit<WriteCommand>}} methods (e.g. visitpPutKeyValueCommand) and does not acquire write locks on these invocations but read locks
* read locks are acquired similar to {{LockingInterceptor.visitGetKeyValueCommand()}}:
{code:java}
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable {
try {
entryFactory.wrapEntryForReading(ctx, command.getKey());
return invokeNextInterceptor(ctx, command);
} finally {
doAfterCall(ctx);
}
}
{code}
* {{PrepareTimeLockingInterceptor.visitPrepareCommand}} overrides {{LockingInterceptor.visitPrepareCommand}}:
{code:java}
@Override
public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command) throws Throwable {
super.visitPrepareCommand(ctx, command);
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
return invokeNextInterceptor(ctx, command);
}
{code}
* {{acquireLock()}} in the code above acquires locks *exactly* the same way {{LockingInterceptor}} would do for a given command.
** E.g. {{acquireLock(PutKeyValueCommand)}} is equivalent with {{LockingInterceptor.visitPutKeyValueCommand(..)}}
** if in distributed mode, the acquire lock *only* acquires a lock if the key(s) within {{WriteCommand}} map to the local node
> Locking optimization: acquire (write) locks at prepare time
> -----------------------------------------------------------
>
> Key: ISPN-1131
> URL: https://issues.jboss.org/browse/ISPN-1131
> Project: Infinispan
> Issue Type: Feature Request
> Reporter: Mircea Markus
> Assignee: Manik Surtani
> Labels: locking, optimization
> Fix For: 5.1.0.Final
>
>
> Detailed here, as the 1st improvement: http://community.jboss.org/wiki/PossibleLockingImprovements
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the infinispan-issues
mailing list