Repository: ignite Updated Branches: refs/heads/ignite-601 865803b66 -> 0b4e230c6
IGNITE-10785: MVCC: Fix TxRollbackAsyncTest. This closes #5735. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a0164b47 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a0164b47 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a0164b47 Branch: refs/heads/ignite-601 Commit: a0164b47139adb0a28ec8f4f4e5fbc401bae16e0 Parents: 601d956 Author: rkondakov <kondako...@mail.ru> Authored: Tue Dec 25 17:10:34 2018 +0300 Committer: Igor Seliverstov <gvvinbl...@gmail.com> Committed: Tue Dec 25 17:10:34 2018 +0300 ---------------------------------------------------------------------- .../cache/transactions/TxRollbackAsyncTest.java | 33 ++++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a0164b47/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java index b3bf376..c480c2d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java @@ -51,7 +51,6 @@ import org.apache.ignite.events.EventType; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteFutureCancelledCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -350,14 +349,14 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest { */ private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockNode, final boolean useTimeout) throws Exception { - final CountDownLatch keyLocked = new CountDownLatch(1); + final GridFutureAdapter<Void> keyLocked = new GridFutureAdapter<>(); CountDownLatch waitCommit = new CountDownLatch(1); // Used for passing tx instance to rollback thread. IgniteInternalFuture<?> lockFut = lockInTx(holdLockNode, keyLocked, waitCommit, 0); - U.awaitQuiet(keyLocked); + keyLocked.get(); final int txCnt = SF.applyLB(250, 25); @@ -380,8 +379,6 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest { IgniteInternalFuture<?> txFut = multithreadedAsync(new Runnable() { @Override public void run() { - U.awaitQuiet(keyLocked); - for (int i = 0; i < txCnt; i++) { GridNearTxLocal tx0 = ctx.tm().threadLocalTx(cctx); @@ -839,7 +836,7 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest { */ @Test public void testRollbackProxy() throws Exception { - final CountDownLatch keyLocked = new CountDownLatch(1); + final GridFutureAdapter<Void> keyLocked = new GridFutureAdapter<>(); CountDownLatch waitCommit = new CountDownLatch(1); @@ -847,7 +844,7 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest { IgniteInternalFuture<?> lockFut = lockInTx(ig, keyLocked, waitCommit, 0); - U.awaitQuiet(keyLocked); + keyLocked.get(); Collection<Transaction> txs = ig.transactions().localActiveTransactions(); @@ -1048,29 +1045,31 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest { * Locks entry in tx and delays commit until signalled. * * @param node Near node. - * @param keyLocked Latch for notifying until key is locked. + * @param keyLocked Future to be done when key is locked. * @param waitCommit Latch for waiting until commit is allowed. * @param timeout Timeout. * @return tx completion future. */ - private IgniteInternalFuture<?> lockInTx(final Ignite node, final CountDownLatch keyLocked, + private IgniteInternalFuture<?> lockInTx(final Ignite node, final GridFutureAdapter<Void> keyLocked, final CountDownLatch waitCommit, final int timeout) throws Exception { return multithreadedAsync(new Runnable() { @Override public void run() { - Transaction tx = node.transactions().withLabel(LABEL).txStart(PESSIMISTIC, REPEATABLE_READ, timeout, 1); + try { + Transaction tx = node.transactions().withLabel(LABEL).txStart(PESSIMISTIC, REPEATABLE_READ, timeout, 1); - node.cache(CACHE_NAME).put(0, 0); + node.cache(CACHE_NAME).put(0, 0); - keyLocked.countDown(); + keyLocked.onDone(); - try { U.await(waitCommit); + + tx.commit(); } - catch (IgniteInterruptedCheckedException e) { - fail("Lock thread was interrupted while waiting"); - } + catch (Throwable e) { + keyLocked.onDone(e); - tx.commit(); + throw new RuntimeException(e); + } } }, 1, "tx-lock-thread"); }