Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5EDEA200D0A for ; Tue, 19 Sep 2017 16:45:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5DBBC1609DD; Tue, 19 Sep 2017 14:45:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 062FA1609DB for ; Tue, 19 Sep 2017 16:45:29 +0200 (CEST) Received: (qmail 53130 invoked by uid 500); 19 Sep 2017 14:45:29 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 52726 invoked by uid 99); 19 Sep 2017 14:45:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2017 14:45:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BA823F59F2; Tue, 19 Sep 2017 14:45:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Tue, 19 Sep 2017 14:46:06 -0000 Message-Id: <72789b0bb8c74f2aa0b7cb1dd9c4f070@git.apache.org> In-Reply-To: <3f3b6244698b4ca1a42538d800915588@git.apache.org> References: <3f3b6244698b4ca1a42538d800915588@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [40/50] [abbrv] ignite git commit: IGNITE-6181 wip. archived-at: Tue, 19 Sep 2017 14:45:33 -0000 IGNITE-6181 wip. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ab4316ae Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ab4316ae Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ab4316ae Branch: refs/heads/ignite-6181-1 Commit: ab4316ae965bb46af6521ff545956614b2dec62a Parents: 0e2ff6a Author: Aleksei Scherbakov Authored: Thu Sep 14 18:31:28 2017 +0300 Committer: Aleksei Scherbakov Committed: Thu Sep 14 18:31:28 2017 +0300 ---------------------------------------------------------------------- .../cache/distributed/near/GridNearTxLocal.java | 30 ++++++----- .../transactions/TxRollbackOnTimeoutTest.java | 56 +++++++++++++++----- 2 files changed, 61 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ab4316ae/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 ee3d1d9..0e75b69 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 @@ -3139,6 +3139,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)prepFut; if (fut == null) { + removeTimeoutHandler(); + long timeout = remainingTime(); // Future must be created before any exception can be thrown. @@ -3163,8 +3165,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou // Prepare was called explicitly. return fut; - removeTimeoutHandler(); - mapExplicitLocks(); fut.prepare(); @@ -3710,9 +3710,12 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou if (state != ROLLING_BACK && state != ROLLED_BACK && state != COMMITTING && state != COMMITTED) rollback(); - else + else { cctx.tm().onLocalClose(this); + removeTimeoutHandler(); + } + synchronized (this) { try { while (!done()) @@ -4023,10 +4026,10 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou } /** - * Removes timeout handler used for eager rollbacks on timeouts. + * Removes timeout handler. */ private void removeTimeoutHandler() { - if (timeout() > 0 && !implicit() && !timedOut()) + if (timeout() > 0 && !implicit()) cctx.time().removeTimeoutObject(this); } @@ -4037,12 +4040,12 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou /** {@inheritDoc} */ @Override public long endTime() { - return startTime() + timeout() - 150; + return startTime() + timeout(); } /** {@inheritDoc} */ @Override public void onTimeout() { - //if (state(MARKED_ROLLBACK, true)) { + if (state(MARKED_ROLLBACK, true)) { cctx.kernalContext().closure().runLocalSafe(new Runnable() { @Override public void run() { // Wait for active local lock futures completion to prevent races with deadlock detection. @@ -4060,15 +4063,16 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou } } - if (state(MARKED_ROLLBACK, true)) { - log().error("Transaction is timed out and will be rolled back [timeout=" + timeout() + - ", tx=" + GridNearTxLocal.this + ']'); + if (state() != MARKED_ROLLBACK) + return; - rollbackNearTxLocalAsync(); - } + log().error("Transaction is timed out and will be rolled back [timeout=" + timeout() + + ", tx=" + GridNearTxLocal.this + ']'); + + rollbackNearTxLocalAsync(); } }); - //} + } } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/ab4316ae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java index 025332ae..4bbff17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java @@ -23,7 +23,6 @@ import javax.cache.CacheException; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; -import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; @@ -218,12 +217,43 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ - public void testDeadlockUnblockedOnTimeout() throws Exception { + public void testDeadlockUnblockedOnTimeout1() throws Exception { testDeadlockUnblockedOnTimeout0(ignite(0), ignite(1)); } /** * Tests if deadlock is resolved on timeout with correct message. + * + * @throws Exception If failed. + */ + public void testDeadlockUnblockedOnTimeout2() throws Exception { + testDeadlockUnblockedOnTimeout0(ignite(0), ignite(0)); + } + + /** + * Tests if deadlock is resolved on timeout with correct message. + * + * @throws Exception If failed. + */ + public void testDeadlockUnblockedOnTimeout3() throws Exception { + Ignite client = startGrid("client"); + + testDeadlockUnblockedOnTimeout0(ignite(0), client); + } + + /** + * Tests if deadlock is resolved on timeout with correct message. + * + * @throws Exception If failed. + */ +// public void testDeadlockUnblockedOnTimeout4() throws Exception { +// Ignite client = startGrid("client"); +// +// testDeadlockUnblockedOnTimeout0(client, ignite(0)); +// } + + /** + * Tests if deadlock is resolved on timeout with correct message. * @throws Exception */ private void testDeadlockUnblockedOnTimeout0(final Ignite node1, final Ignite node2) throws Exception { @@ -232,7 +262,7 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { IgniteInternalFuture fut1 = multithreadedAsync(new Runnable() { @Override public void run() { try { - try (Transaction tx = ignite(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ, TX_TIMEOUT, 2)) { + try (Transaction tx = node1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, TX_TIMEOUT, 2)) { node1.cache(CACHE_NAME).put(1, 1); l.countDown(); @@ -253,7 +283,7 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { IgniteInternalFuture fut2 = multithreadedAsync(new Runnable() { @Override public void run() { - try (Transaction tx = ignite(1).transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 0, 2)) { + try (Transaction tx = node2.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 0, 2)) { node2.cache(CACHE_NAME).put(2, 2); l.countDown(); @@ -346,6 +376,8 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { * @throws Exception If failed. */ private void testTimeoutRemoval0(IgniteEx near, int mode, long timeout) throws Exception { + Throwable saved = null; + try (Transaction tx = near.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, timeout, 1)) { near.cache(CACHE_NAME).put(1, 1); @@ -373,18 +405,18 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { fail(); } } - catch (TransactionTimeoutException e) { - // No-op. - } - catch (CacheException e) { - assertTrue("Only timeout exception is possible", X.hasCause(e, TransactionTimeoutException.class)); + catch (Throwable t) { + saved = t; } GridConcurrentSkipListSet set = U.field(near.context().cache().context().time(), "timeoutObjs"); for (Object obj : set) - assertFalse("Not remove for mode=" + mode + " and timeout=" + timeout, - obj.getClass().isAssignableFrom(GridNearTxLocal.class)); + if (obj.getClass().isAssignableFrom(GridNearTxLocal.class)) { + log.error("Last saved exception", saved); + + fail("Not remove for mode=" + mode + " and timeout=" + timeout); + } } /** @@ -393,7 +425,7 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { * @throws Exception If failed. */ private void testWaitingTxUnblockedOnTimeout0(final Ignite near, final Ignite other) throws Exception { - final int recordsCnt = 1; + final int recordsCnt = 100; IgniteInternalFuture fut1 = multithreadedAsync(new Runnable() { @Override public void run() {