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/12/19 12:20:46 UTC
[47/61] [abbrv] ignite git commit: IGNITE-9902 Fixed ScanQuery to
account for LOST partitions - Fixes #5464.
IGNITE-9902 Fixed ScanQuery to account for LOST partitions - Fixes #5464.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/afe23b60
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/afe23b60
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/afe23b60
Branch: refs/heads/ignite-10639
Commit: afe23b60bbbf4938cb7c471f20a59b51a7ad26a8
Parents: 64e0e69
Author: Alexey Platonov <ap...@gmail.com>
Authored: Tue Dec 18 17:35:34 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Dec 18 17:35:34 2018 +0300
----------------------------------------------------------------------
.../cache/query/GridCacheQueryAdapter.java | 25 +++++++++++++++++---
.../IgniteCachePartitionLossPolicySelfTest.java | 24 ++++++++++++++++---
2 files changed, 43 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/afe23b60/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index 36ee3ba..6f3772c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -33,6 +33,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.PartitionLossPolicy;
import org.apache.ignite.cache.query.Query;
import org.apache.ignite.cache.query.QueryMetrics;
import org.apache.ignite.cluster.ClusterGroup;
@@ -537,9 +538,17 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
cctx.checkSecurity(SecurityPermission.CACHE_READ);
if (nodes.isEmpty()) {
- if (part != null && forceLocal)
- throw new IgniteCheckedException("No queryable nodes for partition " + part
- + " [forced local query=" + this + "]");
+ if (part != null) {
+ if (forceLocal) {
+ throw new IgniteCheckedException("No queryable nodes for partition " + part
+ + " [forced local query=" + this + "]");
+ }
+
+ if (isSafeLossPolicy()) {
+ throw new IgniteCheckedException("Failed to execute scan query because cache partition has been " +
+ "lost [cacheName=" + cctx.name() + ", part=" + part + "]");
+ }
+ }
return new GridEmptyCloseableIterator();
}
@@ -588,6 +597,16 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
}
/**
+ * @return true if current PartitionLossPolicy corresponds to *_SAFE values.
+ */
+ private boolean isSafeLossPolicy() {
+ PartitionLossPolicy lossPlc = cctx.cache().configuration().getPartitionLossPolicy();
+
+ return lossPlc == PartitionLossPolicy.READ_ONLY_SAFE ||
+ lossPlc == PartitionLossPolicy.READ_WRITE_SAFE;
+ }
+
+ /**
* @return Nodes to execute on.
*/
private Collection<ClusterNode> nodes() throws IgniteCheckedException {
http://git-wip-us.apache.org/repos/asf/ignite/blob/afe23b60/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
index 3855c39..70d139f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
@@ -32,6 +32,7 @@ import javax.cache.CacheException;
import junit.framework.AssertionFailedError;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.PartitionLossPolicy;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
@@ -837,9 +838,26 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
* @param parts Partitions.
*/
protected void checkQueryFails(Ignite node, boolean loc, int... parts) {
- // TODO Scan queries never fail due to partition loss - https://issues.apache.org/jira/browse/IGNITE-9902.
- // TODO Need to add an actual check after https://issues.apache.org/jira/browse/IGNITE-9902 is fixed.
- // No-op.
+ if (parts.length == 0)
+ return;
+
+ IgniteCache cache = node.cache(DEFAULT_CACHE_NAME);
+
+ String msg = loc ? "forced local query" : "partition has been lost";
+ GridTestUtils.assertThrows(log, () -> {
+ List res = null;
+ for (int partition : parts) {
+ ScanQuery qry = new ScanQuery();
+ qry.setPartition(partition);
+
+ if (loc)
+ qry.setLocal(true);
+
+ res = cache.query(qry).getAll();
+ }
+
+ return res;
+ }, IgniteCheckedException.class, msg);
}
/** */