[
https://issues.jboss.org/browse/ISPN-1131?page=com.atlassian.jira.plugin....
]
Mircea Markus edited comment on ISPN-1131 at 6/30/11 9:36 AM:
--------------------------------------------------------------
In infinispan 5.1 this will be default locking model, replacing the current one.
In order to enable it use the following configuration element:
{code:xml}
<locking mode="optimistic"
isolationLevel="READ_COMMITTED" />
{code}
The LockingInterceptor needs to be changed in order not to acquire read locks for writes:
{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}
Also following logic will be appended to LockingInterceptor.visitPrepareCommand, before
invokeNextInterceptor:
{code:java}
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
{code}
acquireLock() in the code above acquires locks exactly the same way LockingInterceptor
does 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):
In infinispan 5.1 this will be default locking model, enabled by default.
In order to enable it use the following configuration element:
{code:xml}
<locking mode="optimistic"
isolationLevel="READ_COMMITTED" />
{code}
The LockingInterceptor needs to be changed in order not to acquire read locks for writes:
{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}
Also following logic will be appended to LockingInterceptor.visitPrepareCommand, before
invokeNextInterceptor:
{code:java}
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
{code}
acquireLock() in the code above acquires locks exactly the same way LockingInterceptor
does 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
Acquire (write) locks at prepare time even on local node
--------------------------------------------------------
Key: ISPN-1131
URL:
https://issues.jboss.org/browse/ISPN-1131
Project: Infinispan
Issue Type: Feature Request
Reporter: Mircea Markus
Assignee: Mircea Markus
Labels: locking, optimization
Fix For: 5.1.0.BETA1, 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