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/d6f0b261 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d6f0b261 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d6f0b261 Branch: refs/heads/ignite-6181-1 Commit: d6f0b261bb120d719a0af865f10df55c351eabb5 Parents: 9da2dde Author: Aleksei Scherbakov <alexey.scherbak...@gmail.com> Authored: Wed Aug 30 19:47:11 2017 +0300 Committer: Aleksei Scherbakov <alexey.scherbak...@gmail.com> Committed: Wed Aug 30 19:47:11 2017 +0300 ---------------------------------------------------------------------- .../apache/ignite/IgniteSystemProperties.java | 6 +++ .../cache/distributed/near/GridNearTxLocal.java | 15 ++++++- .../transactions/TxRollbackOnTimeoutTest.java | 43 ++++++++++++++------ 3 files changed, 50 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d6f0b261/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index d3cba2b..c22d552 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -706,6 +706,12 @@ public final class IgniteSystemProperties { public static final String IGNITE_ENABLE_FORCIBLE_NODE_KILL = "IGNITE_ENABLE_FORCIBLE_NODE_KILL"; /** + * If this property is set, a node will track transaction initiators, printing them in tx timeout error. + * Useful for debugging. + */ + public static final String IGNITE_TRACK_TRANSACTION_INITIATOR = "IGNITE_TRACK_TRANSACTION_INITIATOR"; + + /** * Enforces singleton. */ private IgniteSystemProperties() { http://git-wip-us.apache.org/repos/asf/ignite/blob/d6f0b261/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 ebae49f..84c9790 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 @@ -34,6 +34,7 @@ import javax.cache.CacheException; import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; @@ -114,11 +115,17 @@ import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK; import static org.apache.ignite.transactions.TransactionState.ROLLING_BACK; import static org.apache.ignite.transactions.TransactionState.UNKNOWN; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_TRACK_TRANSACTION_INITIATOR; + /** * Replicated user transaction. */ @SuppressWarnings("unchecked") public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeoutObject, AutoCloseable { + /** {@link IgniteSystemProperties#IGNITE_TRACK_TRANSACTION_INITIATOR} */ + private static final boolean TRACK_TRANSACTION_INITIATOR = + IgniteSystemProperties.getBoolean(IGNITE_TRACK_TRANSACTION_INITIATOR, false); + /** */ private static final long serialVersionUID = 0L; @@ -177,6 +184,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou /** */ private long endTime; + /** */ + private transient Exception trackE; + /** * Empty constructor required for {@link Externalizable}. */ @@ -233,6 +243,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou mappings = implicitSingle ? new IgniteTxMappingsSingleImpl() : new IgniteTxMappingsImpl(); if (this.timeout > 0) { + if (TRACK_TRANSACTION_INITIATOR) + trackE = new Exception(); + endTime = U.currentTimeMillis() + this.timeout; cctx.time().addTimeoutObject(this); @@ -4072,7 +4085,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou /** {@inheritDoc} */ @Override public void onTimeout() { - log.error("Transaction is timed out and will be rolled back: [tx=" + this + ']'); + log.error("Transaction is timed out and will be rolled back: [tx=" + this + ']', trackE); if (setRollbackOnly()) rollbackAsync(); http://git-wip-us.apache.org/repos/asf/ignite/blob/d6f0b261/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 e93cff1..52f099d 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 @@ -22,12 +22,14 @@ import java.util.concurrent.TimeUnit; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; import org.apache.ignite.internal.util.GridConcurrentSkipListSet; @@ -53,13 +55,13 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); /** */ - private final CountDownLatch blocked = new CountDownLatch(1); + private static final int GRID_CNT = 3; /** */ - private CountDownLatch unblocked = new CountDownLatch(1); + private final CountDownLatch blocked = new CountDownLatch(1); /** */ - private static int GRID_CNT = 3; + private CountDownLatch unblocked = new CountDownLatch(1); /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -84,6 +86,20 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + System.setProperty(IgniteSystemProperties.IGNITE_TRACK_TRANSACTION_INITIATOR, "true"); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + + System.clearProperty(IgniteSystemProperties.IGNITE_TRACK_TRANSACTION_INITIATOR); + } + + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -114,11 +130,11 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { /** * Tests if timeout on first tx unblocks second tx waiting for the locked key. */ - public void testWaitingTxUnblockedOnTimeout3() throws Exception { - Ignite client = startGrid("client"); - - testWaitingTxUnblockedOnTimeout0(grid(0), client); - } +// public void testWaitingTxUnblockedOnTimeout3() throws Exception { +// Ignite client = startGrid("client"); +// +// testWaitingTxUnblockedOnTimeout0(grid(0), client); +// } /** * Tests if timeout on first tx unblocks second tx waiting for the locked key. @@ -155,11 +171,11 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { /** * Tests if timeout on first tx unblocks second tx waiting for the locked key. */ - public void testWaitingTxUnblockedOnTimeout8() throws Exception { - Ignite client = startGrid("client"); - - testWaitingTxUnblockedOnThreadDeath0(grid(0), client); - } +// public void testWaitingTxUnblockedOnTimeout8() throws Exception { +// Ignite client = startGrid("client"); +// +// testWaitingTxUnblockedOnThreadDeath0(grid(0), client); +// } /** * Tests if timeout on first tx unblocks second tx waiting for the locked key. @@ -259,6 +275,7 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest { fut1.get(5, TimeUnit.SECONDS); } + /** */ private void testWaitingTxUnblockedOnThreadDeath0(final Ignite near, final Ignite other) throws Exception { final int recordsCnt = 100;