You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/05/29 14:39:13 UTC

ignite git commit: IGNITE-8624 Added reproducer of IGNITE-8624 issue. - Fixes #4077.

Repository: ignite
Updated Branches:
  refs/heads/master b69ac8659 -> d191cef44


IGNITE-8624 Added reproducer of IGNITE-8624 issue. - Fixes #4077.

Signed-off-by: Dmitriy Pavlov <dp...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d191cef4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d191cef4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d191cef4

Branch: refs/heads/master
Commit: d191cef440b850bdfe975dffadceaa838f5427f1
Parents: b69ac86
Author: Ivan Daschinskiy <iv...@gmail.com>
Authored: Tue May 29 17:38:38 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Tue May 29 17:38:38 2018 +0300

----------------------------------------------------------------------
 .../cache/transactions/TxOnCachesStartTest.java | 141 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite6.java       |   9 +-
 2 files changed, 147 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d191cef4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
new file mode 100644
index 0000000..2404404
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.transactions;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *  Tests transactions closes correctly while other caches start and stop.
+ *  Tests possible {@link NullPointerException} in {@link TransactionProxyImpl#leave} due to race while
+ *  {@link org.apache.ignite.internal.processors.cache.GridCacheTtlManager} initializes (IGNITE-7972).
+ */
+public class TxOnCachesStartTest extends GridCommonAbstractTest {
+    /** */
+    private static int NUM_CACHES = 100;
+
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTransactionCloseOnCachesStartAndStop() throws Exception {
+        Ignite srv =  startGrids(5);
+
+        IgniteEx client1 = startGrid(getConfiguration("client-1").setClientMode(true));
+
+        srv.cluster().active(true);
+
+        CountDownLatch latch = new CountDownLatch(1);
+
+        AtomicReference<NullPointerException> ex = new AtomicReference<>(null);
+
+        IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+            @Override public void run() {
+                for (int i = 0; i < NUM_CACHES; i++) {
+                    IgniteCache cache = client1.getOrCreateCache(testCacheConfiguration(DEFAULT_CACHE_NAME + i));
+
+                    try {
+                        U.sleep(100);
+                    }
+                    catch (Exception e) {
+                        //Ignore.
+                    }
+
+                    cache.destroy();
+                }
+            }
+        }, 1, "tx-thread");
+
+        GridTestUtils.runMultiThreadedAsync(new Runnable() {
+            @Override public void run()  {
+                while (true) {
+                    try (Transaction tx = client1.transactions().txStart()) {
+                        /** Empty transaction, just testing {@link TransactionProxyImpl#leave} */
+                    }
+                    catch (NullPointerException e) {
+                        e.printStackTrace();
+
+                        ex.compareAndSet(null, e);
+
+                        latch.countDown();
+
+                        break;
+                    }
+                }
+            }
+        }, 1, "tx-thread");
+
+        latch.await(5, TimeUnit.SECONDS);
+
+        fut.cancel();
+
+        assertNull("NullPointerException thrown while closing transaction", ex.get());
+    }
+
+    /**
+     * Get cache configuration for tests.
+     *
+     * @param name Name.
+     */
+    private CacheConfiguration testCacheConfiguration(String name) {
+        return new CacheConfiguration()
+                .setGroupName("default-group")
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                   .setName(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d191cef4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
index fb0daa9..66c1c48 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
@@ -44,14 +44,15 @@ import org.apache.ignite.internal.processors.cache.distributed.IgnitePessimistic
 import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheAssignmentNodeRestartsTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxLabelTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxMultiCacheAsyncOpsTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxOnCachesStartTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticOnPartitionExchangeTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticPrepareOnUnstableTopologyTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncNearCacheTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncWithPersistenceTest;
-import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticOnPartitionExchangeTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutNearCacheTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutNoDeadlockDetectionTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutTest;
-import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncNearCacheTest;
-import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncTest;
 import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTopologyChangeTest;
 
 /**
@@ -89,6 +90,8 @@ public class IgniteCacheTestSuite6 extends TestSuite {
 
         suite.addTestSuite(TxMultiCacheAsyncOpsTest.class);
 
+        suite.addTestSuite(TxOnCachesStartTest.class);
+
         suite.addTestSuite(IgnitePdsCacheAssignmentNodeRestartsTest.class);
 
         suite.addTestSuite(WalModeChangeSelfTest.class);