ignite-6137: CAS logic fix in async commit This closes #2496.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8610471e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8610471e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8610471e Branch: refs/heads/ignite-6149 Commit: 8610471ed8d28c600268407be1a2d6ddfbf45f6c Parents: 91cf66e Author: sboikov <[email protected]> Authored: Fri Sep 15 13:49:56 2017 +0300 Committer: sboikov <[email protected]> Committed: Fri Sep 15 13:49:56 2017 +0300 ---------------------------------------------------------------------- .../cache/distributed/near/GridNearTxLocal.java | 2 +- .../IgniteCacheSystemTransactionsSelfTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8610471e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java index c55276c..058a3ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java @@ -3218,7 +3218,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements AutoClosea GridNearTxFinishFuture fut = commitFut; - if (fut == null && + if (fut != null || !COMMIT_FUT_UPD.compareAndSet(this, null, fut = new GridNearTxFinishFuture<>(cctx, this, true))) return commitFut; http://git-wip-us.apache.org/repos/asf/ignite/blob/8610471e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java index e667c49..eb19873 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java @@ -33,8 +33,10 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.transactions.Transaction; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; /** * Tests that system transactions do not interact with user transactions. @@ -105,6 +107,22 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf /** * @throws Exception If failed. */ + public void testGridNearTxLocalDuplicateAsyncCommit() throws Exception { + IgniteKernal ignite = (IgniteKernal)grid(0); + + IgniteInternalCache<Object, Object> utilityCache = ignite.context().cache().utilityCache(); + + try (GridNearTxLocal itx = utilityCache.txStartEx(OPTIMISTIC, SERIALIZABLE)) { + utilityCache.put("1", "1"); + + itx.commitNearTxLocalAsync(); + itx.commitNearTxLocalAsync().get(); + } + } + + /** + * @throws Exception If failed. + */ private void checkTransactionsCommitted() throws Exception { for (int i = 0; i < gridCount(); i++) { IgniteKernal kernal = (IgniteKernal)grid(i);
