Permalink
Browse files

ISPN-2847 Puts done by state transfer can fail with TimeoutException …

…if lock cannot be acquired

A state transfer transaction should not wait for the backup locks of other transactions
  • Loading branch information...
1 parent eed8230 commit 2673c1b2f64b5250a633646b3c1c884613e5e4e8 @anistor anistor committed with danberindei Mar 8, 2013
@@ -245,6 +245,10 @@ private Object enlistWriteAndInvokeNext(InvocationContext ctx, WriteCommand comm
localTransaction = enlist((TxInvocationContext) ctx);
LocalTxInvocationContext localTxContext = (LocalTxInvocationContext) ctx;
localTxContext.setLocalTransaction(localTransaction);
+ if (command.hasFlag(Flag.PUT_FOR_STATE_TRANSFER)) {
+ // mark the transaction as originating from state transfer as early as possible
+ localTransaction.setFromStateTransfer(true);
+ }
}
Object rv;
try {
@@ -34,6 +34,7 @@
import org.infinispan.context.impl.TxInvocationContext;
import org.infinispan.factories.annotations.Inject;
import org.infinispan.remoting.rpc.RpcManager;
+import org.infinispan.transaction.LocalTransaction;
import org.infinispan.transaction.TransactionTable;
import org.infinispan.transaction.xa.CacheTransaction;
import org.infinispan.transaction.xa.GlobalTransaction;
@@ -147,18 +148,18 @@ protected final void lockAndRegisterBackupLock(TxInvocationContext ctx, Object k
* when the cluster is stable.
*/
protected final void lockKeyAndCheckOwnership(InvocationContext ctx, Object key, long lockTimeout, boolean skipLocking) throws InterruptedException {
- //this is possible when the put is originated as a result of a state transfer
- if (!ctx.isInTxScope()) {
- lockManager.acquireLock(ctx, key, lockTimeout, skipLocking);
- return;
- }
TxInvocationContext txContext = (TxInvocationContext) ctx;
int transactionTopologyId = -1;
boolean checkForPendingLocks = false;
if (clustered) {
- transactionTopologyId = txContext.getCacheTransaction().getTopologyId();
- if (transactionTopologyId != TransactionTable.CACHE_STOPPED_TOPOLOGY_ID) {
- checkForPendingLocks = txTable.getMinTopologyId() < transactionTopologyId;
+ CacheTransaction tx = txContext.getCacheTransaction();
+ boolean isFromStateTransfer = txContext.isOriginLocal() && ((LocalTransaction)tx).isFromStateTransfer();
+ // if the transaction is from state transfer it should not wait for the backup locks of other transactions
+ if (!isFromStateTransfer) {
+ transactionTopologyId = tx.getTopologyId();
+ if (transactionTopologyId != TransactionTable.CACHE_STOPPED_TOPOLOGY_ID) {
+ checkForPendingLocks = txTable.getMinTopologyId() < transactionTopologyId;
+ }
}
}
@@ -30,28 +30,11 @@
* @author anistor@redhat.com
* @since 5.2
*/
-@Test(groups = "functional", testName = "statetransfer.DistPessimisticTxOperationsDuringStateTransferTest",
- enabled = false, description = "Disabled due to https://issues.jboss.org/browse/ISPN-2847")
+@Test(groups = "functional", testName = "statetransfer.DistPessimisticTxOperationsDuringStateTransferTest")
@CleanupAfterMethod
public class DistPessimisticTxOperationsDuringStateTransferTest extends BaseOperationsDuringStateTransferTest {
public DistPessimisticTxOperationsDuringStateTransferTest() {
super(CacheMode.DIST_SYNC, true, false, false);
}
-
- @Test(enabled = false)
- public void testPut() throws Exception {
- }
-
- @Test(enabled = false)
- public void testReplace() throws Exception {
- }
-
- @Test(enabled = false)
- public void testGet() throws Exception {
- }
-
- @Test(enabled = false)
- public void testRemove() throws Exception {
- }
}
@@ -30,28 +30,11 @@
* @author anistor@redhat.com
* @since 5.2
*/
-@Test(groups = "functional", testName = "statetransfer.ReplPessimisticOperationsDuringStateTransferTest",
- enabled = false, description = "Disabled due to https://issues.jboss.org/browse/ISPN-2847")
+@Test(groups = "functional", testName = "statetransfer.ReplPessimisticOperationsDuringStateTransferTest")
@CleanupAfterMethod
public class ReplPessimisticOperationsDuringStateTransferTest extends BaseOperationsDuringStateTransferTest {
public ReplPessimisticOperationsDuringStateTransferTest() {
super(CacheMode.REPL_SYNC, true, false, false);
}
-
- @Test(enabled = false)
- public void testPut() throws Exception {
- }
-
- @Test(enabled = false)
- public void testReplace() throws Exception {
- }
-
- @Test(enabled = false)
- public void testGet() throws Exception {
- }
-
- @Test(enabled = false)
- public void testRemove() throws Exception {
- }
}

0 comments on commit 2673c1b

Please sign in to comment.