You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by gv...@apache.org on 2019/01/30 13:58:21 UTC

[ignite] branch master updated: IGNITE-10377: MVCC: Incorrect exception on no data nodes found for a partition fixed. This closes #5823.

This is an automated email from the ASF dual-hosted git repository.

gvvinblade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 15bf6cf  IGNITE-10377: MVCC: Incorrect exception on no data nodes found for a partition fixed. This closes #5823.
15bf6cf is described below

commit 15bf6cf864ba5159882ba01e41056bd143439802
Author: Andrey V. Mashenkov <an...@gmail.com>
AuthorDate: Wed Jan 30 16:49:32 2019 +0300

    IGNITE-10377: MVCC: Incorrect exception on no data nodes found for a partition fixed. This closes #5823.
---
 .../internal/processors/cache/GridCacheUtils.java  |  2 +-
 .../cache/IgniteTxExceptionAbstractSelfTest.java   |  6 ++---
 .../dht/NotMappedPartitionInTxTest.java            | 14 +++++-----
 .../query/h2/DmlStatementsProcessor.java           |  5 ++++
 .../query/h2/twostep/ReducePartitionMapper.java    | 30 +++++++++++-----------
 ...acheMvccAbstractSqlCoordinatorFailoverTest.java | 11 ++++----
 6 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 8d8c0e1..6c0b041 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1283,7 +1283,7 @@ public class GridCacheUtils {
      * @param e Ignite checked exception.
      * @return CacheException runtime exception, never null.
      */
-    @NotNull public static RuntimeException convertToCacheException(IgniteCheckedException e) {
+    public static @NotNull RuntimeException convertToCacheException(IgniteCheckedException e) {
         IgniteClientDisconnectedCheckedException disconnectedErr =
             e.getCause(IgniteClientDisconnectedCheckedException.class);
 
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
index e567995..d207aa7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
@@ -99,8 +99,6 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
-        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10377", MvccFeatureChecker.forcedMvcc());
-
         super.beforeTestsStarted();
 
         lastKey = 0;
@@ -200,8 +198,6 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
      */
     @Test
     public void testRemovePrimary() throws Exception {
-        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc());
-
         checkRemove(false, keyForNode(grid(0).localNode(), PRIMARY));
 
         checkRemove(true, keyForNode(grid(0).localNode(), PRIMARY));
@@ -590,6 +586,8 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
      * @throws Exception If failed.
      */
     private void checkRemove(boolean putBefore, final Integer key) throws Exception {
+        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc());
+
         if (putBefore) {
             TestIndexingSpi.forceFail(false);
 
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
index 6d87a54..05dcacd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
@@ -39,7 +39,6 @@ import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.Nullable;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
@@ -113,7 +112,6 @@ public class NotMappedPartitionInTxTest extends GridCommonAbstractTest {
     /**
      *
      */
-    @Ignore("https://issues.apache.org/jira/browse/IGNITE-10377")
     @Test
     public void testOneServerMvcc() throws Exception {
         try {
@@ -158,7 +156,6 @@ public class NotMappedPartitionInTxTest extends GridCommonAbstractTest {
     /**
      *
      */
-    @Ignore("https://issues.apache.org/jira/browse/IGNITE-10377")
     @Test
     public void testFourServersMvcc() throws Exception {
         try {
@@ -170,7 +167,7 @@ public class NotMappedPartitionInTxTest extends GridCommonAbstractTest {
             isClient = true;
             final IgniteEx client = startGrid(4);
 
-            checkNotMapped(client, PESSIMISTIC, READ_COMMITTED);
+            checkNotMapped(client, PESSIMISTIC, REPEATABLE_READ);
         }
         finally {
             stopAllGrids();
@@ -182,8 +179,13 @@ public class NotMappedPartitionInTxTest extends GridCommonAbstractTest {
      */
     private void checkNotMapped(final IgniteEx client, final TransactionConcurrency concurrency,
         final TransactionIsolation isolation) {
-        String msg = concurrency == PESSIMISTIC ? "Failed to lock keys (all partition nodes left the grid)" :
-           "Failed to map keys to nodes (partition is not mapped to any node";
+        String msg;
+
+        if (atomicityMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT)
+            msg = "Failed to get primary node ";
+        else
+            msg = concurrency == PESSIMISTIC ? "Failed to lock keys (all partition nodes left the grid)" :
+                "Failed to map keys to nodes (partition is not mapped to any node";
 
 
         GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 05d3e6ec..7a85e97 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -40,11 +40,13 @@ import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheServerNotFoundException;
 import org.apache.ignite.cache.query.BulkLoadContextCursor;
 import org.apache.ignite.cache.query.FieldsQueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.bulkload.BulkLoadAckClientParameters;
 import org.apache.ignite.internal.processors.bulkload.BulkLoadCacheWriter;
@@ -625,6 +627,9 @@ public class DmlStatementsProcessor {
 
                 return res;
             }
+            catch (ClusterTopologyServerNotFoundException e) {
+                throw new CacheServerNotFoundException(e.getMessage(), e);
+            }
             catch (IgniteCheckedException e) {
                 checkSqlException(e);
 
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReducePartitionMapper.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReducePartitionMapper.java
index d5f037b..608f307 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReducePartitionMapper.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReducePartitionMapper.java
@@ -17,7 +17,17 @@
 
 package org.apache.ignite.internal.processors.query.h2.twostep;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.CacheServerNotFoundException;
 import org.apache.ignite.cache.PartitionLossPolicy;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.GridKernalContext;
@@ -31,16 +41,6 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.h2.util.IntArray;
 import org.jetbrains.annotations.Nullable;
 
-import javax.cache.CacheException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE;
 import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_SAFE;
 import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE;
@@ -194,7 +194,7 @@ public class ReducePartitionMapper {
         Set<ClusterNode> nodes = map.keySet();
 
         if (F.isEmpty(map))
-            throw new CacheException("Failed to find data nodes for cache: " + cctx.name());
+            throw new CacheServerNotFoundException("Failed to find data nodes for cache: " + cctx.name());
 
         for (int i = 1; i < cacheIds.size(); i++) {
             GridCacheContext<?,?> extraCctx = cacheContext(cacheIds.get(i));
@@ -212,7 +212,7 @@ public class ReducePartitionMapper {
             Set<ClusterNode> extraNodes = stableDataNodesMap(topVer, extraCctx, parts).keySet();
 
             if (F.isEmpty(extraNodes))
-                throw new CacheException("Failed to find data nodes for cache: " + extraCacheName);
+                throw new CacheServerNotFoundException("Failed to find data nodes for cache: " + extraCacheName);
 
             boolean disjoint;
 
@@ -353,7 +353,7 @@ public class ReducePartitionMapper {
                     return null; // Retry.
                 }
 
-                throw new CacheException("Failed to find data nodes [cache=" + cctx.name() + ", part=" + p + "]");
+                throw new CacheServerNotFoundException("Failed to find data nodes [cache=" + cctx.name() + ", part=" + p + "]");
             }
 
             partLocs[p] = new HashSet<>(owners);
@@ -389,7 +389,7 @@ public class ReducePartitionMapper {
                             return null; // Retry.
                         }
 
-                        throw new CacheException("Failed to find data nodes [cache=" + extraCctx.name() +
+                        throw new CacheServerNotFoundException("Failed to find data nodes [cache=" + extraCctx.name() +
                             ", part=" + p + "]");
                     }
 
@@ -542,7 +542,7 @@ public class ReducePartitionMapper {
         Set<ClusterNode> dataNodes = new HashSet<>(dataNodes(cctx.groupId(), NONE));
 
         if (dataNodes.isEmpty())
-            throw new CacheException("Failed to find data nodes for cache: " + cacheName);
+            throw new CacheServerNotFoundException("Failed to find data nodes for cache: " + cacheName);
 
         // Find all the nodes owning all the partitions for replicated cache.
         for (int p = 0, parts = cctx.affinity().partitions(); p < parts; p++) {
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java
index ceafe5e..b9526b6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.mvcc;
 
 import java.util.concurrent.Callable;
-import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheServerNotFoundException;
@@ -246,7 +245,7 @@ public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheM
 
                     return null;
                 }
-            }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException.
+            }, CacheServerNotFoundException.class, "Failed to find data nodes for cache");
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
                 @Override public Void call() throws Exception {
@@ -254,7 +253,7 @@ public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheM
 
                     return null;
                 }
-            }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException.
+            }, CacheServerNotFoundException.class, "Failed to find data nodes for cache");
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
                 @Override public Void call() throws Exception {
@@ -262,7 +261,7 @@ public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheM
 
                     return null;
                 }
-            }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException.
+            }, CacheServerNotFoundException.class, "Failed to find data nodes for cache");
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
                 @Override public Void call() throws Exception {
@@ -270,7 +269,7 @@ public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheM
 
                     return null;
                 }
-            }, CacheException.class, "Failed to get primary node"); // TODO IGNITE-10377 should be CacheServerNotFoundException.
+            }, CacheServerNotFoundException.class, "Failed to get primary node");
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
                 @Override public Void call() throws Exception {
@@ -278,7 +277,7 @@ public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheM
 
                     return null;
                 }
-            }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException.
+            }, CacheServerNotFoundException.class, "Failed to find data nodes for cache");
         }
 
         startGrid(1);