[infinispan-issues] [JBoss JIRA] Commented: (ISPN-1131) Locking optimization: acquire (write) locks at prepare time

Mircea Markus (JIRA) jira-events at lists.jboss.org
Mon May 23 16:12:02 EDT 2011


    [ https://issues.jboss.org/browse/ISPN-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603758#comment-12603758 ] 

Mircea Markus commented on ISPN-1131:
-------------------------------------

Suggested design.
When first released, this will be an experimental feature disabled by default. 
It will be possible to enable it by using 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 will be added: {{PrepareTimeLockingInterceptor}}:
* it extends {{LockingInterceptor}}
* when *lockAtPrepareTime* is enabled it takes {{LockingInterceptor}}'s place is the interceptor chain
* it overrides the 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}} also overrides the same method from {{LockingInterceptor}}:
{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