You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2019/07/10 06:33:53 UTC
[ignite] branch master updated: IGNITE-10663 Read Repair (#5656)
This is an automated email from the ASF dual-hosted git repository.
av 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 78d0462 IGNITE-10663 Read Repair (#5656)
78d0462 is described below
commit 78d04620a385c8813b5695ce72c240f5accb43e3
Author: Anton Vinogradov <av...@apache.org>
AuthorDate: Wed Jul 10 09:33:38 2019 +0300
IGNITE-10663 Read Repair (#5656)
---
.../main/java/org/apache/ignite/IgniteCache.java | 35 ++
.../events/CacheConsistencyViolationEvent.java | 69 ++++
.../java/org/apache/ignite/events/EventType.java | 15 +
.../processors/cache/CacheOperationContext.java | 55 ++-
.../cache/GatewayProtectedCacheProxy.java | 34 ++
.../processors/cache/GridCacheAdapter.java | 376 +++++++++++++++++----
.../processors/cache/GridCacheProxyImpl.java | 54 ++-
.../processors/cache/IgniteCacheProxyImpl.java | 5 +
.../cache/distributed/dht/GridDhtCacheAdapter.java | 3 +
.../distributed/dht/GridPartitionedGetFuture.java | 41 ++-
.../distributed/dht/atomic/GridDhtAtomicCache.java | 74 +++-
.../dht/colocated/GridDhtColocatedCache.java | 38 ++-
.../distributed/near/GridNearAtomicCache.java | 3 +-
.../near/GridNearTransactionalCache.java | 2 +
.../cache/distributed/near/GridNearTxLocal.java | 121 ++++++-
.../GridNearReadRepairAbstractFuture.java | 221 ++++++++++++
.../GridNearReadRepairCheckOnlyFuture.java | 176 ++++++++++
.../near/consistency/GridNearReadRepairFuture.java | 166 +++++++++
.../IgniteConsistencyViolationException.java | 36 ++
.../cache/local/atomic/GridLocalAtomicCache.java | 12 +-
.../cache/transactions/IgniteTxEntry.java | 2 +-
.../IgniteTxImplicitSingleStateImpl.java | 5 +
.../cache/transactions/IgniteTxLocalState.java | 5 +
.../cache/transactions/IgniteTxManager.java | 10 +
.../cache/transactions/IgniteTxStateImpl.java | 5 +
.../cache/version/GridCacheVersionManager.java | 2 +-
.../datastructures/GridCacheQueueAdapter.java | 1 +
.../internal/util/future/GridCompoundFuture.java | 14 +-
.../consistency/AbstractFullSetReadRepairTest.java | 242 +++++++++++++
.../cache/consistency/AbstractReadRepairTest.java | 336 ++++++++++++++++++
.../cache/consistency/AtomicReadRepairTest.java | 191 +++++++++++
.../ExplicitTransactionalReadRepairTest.java | 149 ++++++++
.../ImplicitTransactionalReadRepairTest.java | 99 ++++++
...licatedExplicitTransactionalReadRepairTest.java | 30 ++
...licatedImplicitTransactionalReadRepairTest.java | 30 ++
...eBackupExplicitTransactionalReadRepairTest.java | 28 ++
...eBackupImplicitTransactionalReadRepairTest.java | 28 ++
.../GridCacheDhtEvictionNearReadersSelfTest.java | 2 +-
.../junits/multijvm/IgniteCacheProcessProxy.java | 5 +
.../IgniteCacheDataStructuresSelfTestSuite.java | 19 +-
.../internal/processors/query/h2/dml/DmlUtils.java | 2 +-
.../ExpiryCacheHolderTest.cs | 7 +
.../Cache/CacheTestAsyncWrapper.cs | 12 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 13 +
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 34 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 3 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 2 +-
47 files changed, 2682 insertions(+), 130 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 8e6918a..9711a33 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -137,6 +137,41 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public IgniteCache<K, V> withPartitionRecover();
/**
+ * Gets an instance of {@code IgniteCache} that will perform backup nodes check on each get attempt.
+ * <p>
+ * Read Repair means that each backup node will be checked to have the same entry as primary node has,
+ * and in case consistency violation found:
+ * <ul>
+ * <li>for transactional caches:
+ * <p>values across the topology will be replaced by latest versioned value:
+ * <ul>
+ * <li>automaticaly for OPTIMISTIC || READ_COMMITTED transactions</li>
+ * <li>at commit() for PESSIMISTIC && !READ_COMMITTED transactions</li>
+ * </ul>
+ * <p>consistency violation event will be recorded in case it's configured as recordable</li>
+ * <li>for atomic caches: consistency violation exception will be thrown.</li>
+ * </ul>
+ * <p>
+ * One more important thing is that this proxy usage does not guarantee "all copies check" in case value
+ * already cached inside the transaction. In case you use !READ_COMMITTED isolation mode and already have
+ * cached value, for example already read the value or performed a write, you'll gain the cached value.
+ * <p>
+ * Local caches and caches without backups, obviously, can not be checked using this feature.
+ * <p>
+ * Full list of repairable methods:
+ * <ul>
+ * <li>{@link IgniteCache#containsKey} && {@link IgniteCache#containsKeyAsync}</li>
+ * <li>{@link IgniteCache#containsKeys} && {@link IgniteCache#containsKeysAsync}</li>
+ * <li>{@link IgniteCache#getEntry} && {@link IgniteCache#getEntryAsync}</li>
+ * <li>{@link IgniteCache#getEntries} && {@link IgniteCache#getEntriesAsync}</li>
+ * <li>{@link IgniteCache#get} && {@link IgniteCache#getAsync}</li>
+ * <li>{@link IgniteCache#getAll} && {@link IgniteCache#getAllAsync}</li>
+ * </ul>
+ * @return Cache with explicit consistency check on each read and repair if necessary.
+ */
+ public IgniteCache<K, V> withReadRepair();
+
+ /**
* Returns cache that will operate with binary objects.
* <p>
* Cache returned by this method will not be forced to deserialize binary objects,
diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheConsistencyViolationEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheConsistencyViolationEvent.java
new file mode 100644
index 0000000..9fcc889
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/events/CacheConsistencyViolationEvent.java
@@ -0,0 +1,69 @@
+/*
+ * 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.events;
+
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+
+import static org.apache.ignite.events.EventType.EVT_CONSISTENCY_VIOLATION;
+
+/**
+ * Event indicates consistency violation detection.
+ *
+ * @see EventType#EVT_CONSISTENCY_VIOLATION
+ */
+public class CacheConsistencyViolationEvent extends EventAdapter {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 0L;
+
+ /** Original distribution. */
+ Map<UUID /*Node*/, Map<Object /*Key*/, Object /*Value*/>> locEntries;
+
+ /** Fixed entries. */
+ Map<Object /*Key*/, Object /*Value*/> fixedEntries;
+
+ /**
+ *
+ */
+ public CacheConsistencyViolationEvent(
+ ClusterNode node,
+ String msg,
+ Map<UUID, Map<Object, Object>> locEntries,
+ Map<Object, Object> fixedEntries) {
+ super(node, msg, EVT_CONSISTENCY_VIOLATION);
+
+ this.locEntries = locEntries;
+ this.fixedEntries = fixedEntries;
+ }
+
+ /**
+ * Original distribution.
+ */
+ public Map<UUID, Map<Object, Object>> getEntries() {
+ return locEntries;
+ }
+
+ /**
+ * Fixed entries.
+ * Will be fixed in case of transaction commit.
+ */
+ public Map<Object, Object> getFixedEntries() {
+ return fixedEntries;
+ }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
index a2b6ba3..284cea5 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
@@ -18,6 +18,7 @@
package org.apache.ignite.events;
import java.util.List;
+import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteEvents;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -884,6 +885,20 @@ public interface EventType {
public static final int EVT_WAL_SEGMENT_COMPACTED = 134;
/**
+ * Built-in event type: Cache consistency violation detected.
+ * <p>
+ * Fired for each consistency violation incident.
+ * <p>
+ * <p>
+ * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
+ * internal Ignite events and should not be used by user-defined events.
+ *
+ * @see CacheConsistencyViolationEvent
+ * @see IgniteCache#withReadRepair
+ */
+ public static final int EVT_CONSISTENCY_VIOLATION = 135;
+
+ /**
* Built-in event type: Cluster activation state changed.
* <p>
* Fired when cluster activated.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
index 53f9e22..47eea68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
@@ -50,6 +50,9 @@ public class CacheOperationContext implements Serializable {
/** */
private final boolean recovery;
+ /** */
+ private final boolean readRepair;
+
/** Client ID which operates over this projection. */
private final UUID subjId;
@@ -70,19 +73,13 @@ public class CacheOperationContext implements Serializable {
*/
public CacheOperationContext() {
skipStore = false;
-
subjId = null;
-
keepBinary = false;
-
expiryPlc = null;
-
noRetries = false;
-
recovery = false;
-
+ readRepair = false;
dataCenterId = null;
-
allowAtomicOpsInTx = DFLT_ALLOW_ATOMIC_OPS_IN_TX;
}
@@ -92,6 +89,7 @@ public class CacheOperationContext implements Serializable {
* @param keepBinary Keep binary flag.
* @param expiryPlc Expiry policy.
* @param dataCenterId Data center id.
+ * @param readRepair Read Repair.
*/
public CacheOperationContext(
boolean skipStore,
@@ -101,22 +99,17 @@ public class CacheOperationContext implements Serializable {
boolean noRetries,
@Nullable Byte dataCenterId,
boolean recovery,
+ boolean readRepair,
boolean allowAtomicOpsInTx
) {
this.skipStore = skipStore;
-
this.subjId = subjId;
-
this.keepBinary = keepBinary;
-
this.expiryPlc = expiryPlc;
-
this.noRetries = noRetries;
-
this.dataCenterId = dataCenterId;
-
this.recovery = recovery;
-
+ this.readRepair = readRepair;
this.allowAtomicOpsInTx = allowAtomicOpsInTx;
}
@@ -148,6 +141,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -184,6 +178,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -209,6 +204,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -234,6 +230,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -250,6 +247,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -266,6 +264,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
@@ -282,17 +281,42 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
allowAtomicOpsInTx);
}
/**
- * @return Recovery flag.
+ * @param readRepair Read Repair flag.
+ * @return New instance of CacheOperationContext with Read Repair flag.
+ */
+ public CacheOperationContext setReadRepair(boolean readRepair) {
+ return new CacheOperationContext(
+ skipStore,
+ subjId,
+ keepBinary,
+ expiryPlc,
+ noRetries,
+ dataCenterId,
+ recovery,
+ readRepair,
+ allowAtomicOpsInTx);
+ }
+
+ /**
+ * @return Partition recover flag.
*/
public boolean recovery() {
return recovery;
}
/**
+ * @return Read Repair flag.
+ */
+ public boolean readRepair() {
+ return readRepair;
+ }
+
+ /**
* @return No retries flag.
*/
public boolean noRetries() {
@@ -311,6 +335,7 @@ public class CacheOperationContext implements Serializable {
noRetries,
dataCenterId,
recovery,
+ readRepair,
true);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
index ef861b9..8023b00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
@@ -232,6 +232,40 @@ public class GatewayProtectedCacheProxy<K, V> extends AsyncSupportAdapter<Ignite
}
/** {@inheritDoc} */
+ @Override public IgniteCache<K, V> withReadRepair() {
+ CacheOperationGate opGate = onEnter();
+
+ try {
+ if (context().mvccEnabled()) // Can (should?) be supported in future.
+ throw new UnsupportedOperationException("Read Repair is not supported at MVCC mode.");
+
+ if (context().isNear()) // Can be supported in future.
+ throw new UnsupportedOperationException("Read Repair is not supported for near caches.");
+
+ if (context().readThrough()) // Can be supported in future.
+ // Read Repair get operation produces different versions for same entries loaded via readThrough feature.
+ throw new UnsupportedOperationException("Read Repair is not supported for caches with readThrough enabled.");
+
+ if (context().isLocal()) // Can't be supported in future.
+ throw new UnsupportedOperationException("Read Repair is not supported for local caches.");
+
+ if (context().config().getBackups() == 0) // Can't be supported in future.
+ throw new UnsupportedOperationException("Read Repair is suitable only in case " +
+ "at least 1 backup configured for cache.");
+
+ boolean readRepair = opCtx.readRepair();
+
+ if (readRepair)
+ return this;
+
+ return new GatewayProtectedCacheProxy<>(delegate, opCtx.setReadRepair(true), lock);
+ }
+ finally {
+ onLeave(opGate);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <K1, V1> GatewayProtectedCacheProxy<K1, V1> withKeepBinary() {
return keepBinary();
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 6269cf1..a6476fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -42,6 +42,7 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Supplier;
import javax.cache.Cache;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
@@ -93,11 +94,13 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.Grid
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheRawVersionedEntry;
@@ -112,6 +115,7 @@ import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.transactions.TransactionCheckedException;
+import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -166,6 +170,7 @@ import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
/**
* Adapter for different cache implementations.
@@ -501,6 +506,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>(ctx, this, opCtx);
@@ -521,6 +527,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>(ctx, this, opCtx);
@@ -536,6 +543,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)this, opCtx);
@@ -558,6 +566,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>(ctx, this, opCtx);
@@ -573,6 +582,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
true,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>(ctx, this, opCtx);
@@ -588,6 +598,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX);
return new GridCacheProxyImpl<>(ctx, this, opCtx);
@@ -706,7 +717,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
@Override public final IgniteInternalFuture<Boolean> containsKeyAsync(K key) {
A.notNull(key, "key");
- return (IgniteInternalFuture)getAsync(
+ CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ IgniteInternalFuture fut = getAsync(
key,
/*force primary*/ !ctx.config().isReadFromBackup(),
/*skip tx*/false,
@@ -715,6 +728,16 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/*deserialize binary*/false,
/*skip values*/true,
false);
+
+ boolean readRepair = opCtx != null && opCtx.readRepair();
+
+ if (readRepair)
+ return getWithRepairAsync(
+ fut,
+ () -> repairAsync(key, opCtx, true),
+ () -> containsKeyAsync(key));
+
+ return fut;
}
/** {@inheritDoc} */
@@ -733,7 +756,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
CacheOperationContext opCtx = ctx.operationContextPerCall();
- return getAllAsync(
+ return repairableGetAllAsync(
keys,
/*force primary*/ !ctx.config().isReadFromBackup(),
/*skip tx*/false,
@@ -741,6 +764,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/*task name*/null,
/*deserialize binary*/false,
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip values*/true,
/*need ver*/false).chain(new CX1<IgniteInternalFuture<Map<K, V>>, Boolean>() {
@Override public Boolean applyx(IgniteInternalFuture<Map<K, V>> fut) throws IgniteCheckedException {
@@ -1381,7 +1405,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
CacheOperationContext opCtx = ctx.operationContextPerCall();
- return getAllAsync(
+ return repairableGetAllAsync(
F.asList(key),
/*force primary*/true,
/*skip tx*/false,
@@ -1389,6 +1413,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
/*deserialize cache objects*/true,
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip values*/false,
/*need ver*/false).get().get(key);
}
@@ -1399,7 +1424,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
CacheOperationContext opCtx = ctx.operationContextPerCall();
- return getAllAsync(
+ return repairableGetAllAsync(
Collections.singletonList(key),
/*force primary*/true,
/*skip tx*/false,
@@ -1407,6 +1432,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
true,
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip vals*/false,
/*can remap*/false).chain(new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
@Override public V applyx(IgniteInternalFuture<Map<K, V>> e) throws IgniteCheckedException {
@@ -1426,13 +1452,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
CacheOperationContext opCtx = ctx.operationContextPerCall();
- return getAllAsync(keys,
+ return repairableGetAllAsync(keys,
!ctx.config().isReadFromBackup(),
/*skip tx*/true,
null,
taskName,
!(opCtx != null && opCtx.isKeepBinary()),
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip values*/false,
/*need ver*/false);
}
@@ -1450,7 +1477,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (keepBinary)
key = (K)ctx.toCacheKeyObject(key);
- V val = get(key, !keepBinary, false);
+ V val = repairableGet(key, !keepBinary, false);
if (ctx.config().getInterceptor() != null) {
key = keepBinary ? (K)ctx.unwrapBinaryIfNeeded(key, true, false) : key;
@@ -1478,7 +1505,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
key = (K)ctx.toCacheKeyObject(key);
EntryGetResult t
- = (EntryGetResult)get(key, !keepBinary, true);
+ = (EntryGetResult)repairableGet(key, !keepBinary, true);
CacheEntry<K, V> val = t != null ? new CacheEntryImplEx<>(
keepBinary ? (K)ctx.unwrapBinaryIfNeeded(key, true, false) : key,
@@ -1512,7 +1539,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final K key0 = keepBinary ? (K)ctx.toCacheKeyObject(key) : key;
- IgniteInternalFuture<V> fut = getAsync(key, !keepBinary, false);
+ final CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ IgniteInternalFuture<V> fut = repairableGetAsync(
+ key,
+ !keepBinary,
+ false,
+ opCtx != null && opCtx.readRepair());
if (ctx.config().getInterceptor() != null)
fut = fut.chain(new CX1<IgniteInternalFuture<V>, V>() {
@@ -1541,8 +1574,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final K key0 = keepBinary ? (K)ctx.toCacheKeyObject(key) : key;
+ final CacheOperationContext opCtx = ctx.operationContextPerCall();
+
IgniteInternalFuture<EntryGetResult> fut =
- (IgniteInternalFuture<EntryGetResult>)getAsync(key0, !keepBinary, true);
+ (IgniteInternalFuture<EntryGetResult>)repairableGetAsync(
+ key0,
+ !keepBinary,
+ true,
+ opCtx != null && opCtx.readRepair());
final boolean intercept = ctx.config().getInterceptor() != null;
@@ -1584,7 +1623,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
long start = statsEnabled ? System.nanoTime() : 0L;
- Map<K, V> map = getAll0(keys, !ctx.keepBinary(), false);
+ final CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ Map<K, V> map = repairableGetAll(
+ keys,
+ !ctx.keepBinary(),
+ false,
+ opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair());
if (ctx.config().getInterceptor() != null)
map = interceptGet(keys, map);
@@ -1604,7 +1650,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
long start = statsEnabled ? System.nanoTime() : 0L;
- Map<K, EntryGetResult> map = (Map<K, EntryGetResult>)getAll0(keys, !ctx.keepBinary(), true);
+ final CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ Map<K, EntryGetResult> map = (Map<K, EntryGetResult>)repairableGetAll(
+ keys,
+ !ctx.keepBinary(),
+ true,
+ opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair());
Collection<CacheEntry<K, V>> res = new HashSet<>();
@@ -1632,7 +1685,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
CacheOperationContext opCtx = ctx.operationContextPerCall();
- IgniteInternalFuture<Map<K, V>> fut = getAllAsync(
+ IgniteInternalFuture<Map<K, V>> fut = repairableGetAllAsync(
keys,
!ctx.config().isReadFromBackup(),
/*skip tx*/false,
@@ -1640,6 +1693,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
!(opCtx != null && opCtx.isKeepBinary()),
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip vals*/false,
/*need ver*/false);
@@ -1670,7 +1724,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
String taskName = ctx.kernalContext().job().currentTaskName();
IgniteInternalFuture<Map<K, EntryGetResult>> fut =
- (IgniteInternalFuture<Map<K, EntryGetResult>>)((IgniteInternalFuture)getAllAsync(
+ (IgniteInternalFuture<Map<K, EntryGetResult>>)((IgniteInternalFuture)repairableGetAllAsync(
keys,
!ctx.config().isReadFromBackup(),
/*skip tx*/false,
@@ -1678,6 +1732,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
!(opCtx != null && opCtx.isKeepBinary()),
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
/*skip vals*/false,
/*need ver*/true));
@@ -1821,6 +1876,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
opCtx != null && opCtx.recovery(),
+ opCtx != null && opCtx.readRepair(),
skipVals,
needVer).chain(
new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
@@ -1861,6 +1917,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
String taskName,
boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
boolean skipVals,
final boolean needVer
) {
@@ -1876,6 +1933,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
opCtx != null && opCtx.recovery(),
+ readRepair,
forcePrimary,
skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
skipVals,
@@ -1906,6 +1964,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final String taskName,
final boolean deserializeBinary,
final boolean recovery,
+ final boolean readRepair,
final boolean forcePrimary,
@Nullable IgniteCacheExpiryPolicy expiry,
final boolean skipVals,
@@ -1927,6 +1986,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
skipVals,
/*keep cache objects*/false,
recovery,
+ readRepair,
needVer,
null,
null); // TODO IGNITE-7371
@@ -1960,6 +2020,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean skipVals,
final boolean keepCacheObjects,
final boolean recovery,
+ final boolean readRepair,
final boolean needVer,
@Nullable String txLbl,
MvccSnapshot mvccSnapshot
@@ -2325,6 +2386,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
!readThrough,
recovery,
+ readRepair,
needVer);
}
}, ctx.operationContextPerCall(), /*retry*/false);
@@ -4269,7 +4331,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
return t;
}
- catch (IgniteInterruptedCheckedException | IgniteTxHeuristicCheckedException | NodeStoppingException e) {
+ catch (IgniteInterruptedCheckedException |
+ IgniteTxHeuristicCheckedException |
+ NodeStoppingException |
+ IgniteConsistencyViolationException e) {
throw e;
}
catch (IgniteCheckedException e) {
@@ -4421,7 +4486,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
return tFut.get();
}
- catch (IgniteTxTimeoutCheckedException | IgniteTxRollbackCheckedException | NodeStoppingException e) {
+ catch (IgniteTxTimeoutCheckedException |
+ IgniteTxRollbackCheckedException |
+ NodeStoppingException |
+ IgniteConsistencyViolationException e) {
throw e;
}
catch (IgniteCheckedException e1) {
@@ -4732,11 +4800,28 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @return Cached value.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public final V get(K key, boolean deserializeBinary,
- final boolean needVer) throws IgniteCheckedException {
- String taskName = ctx.kernalContext().job().currentTaskName();
+ @Nullable public final V repairableGet(
+ K key,
+ boolean deserializeBinary,
+ boolean needVer) throws IgniteCheckedException {
+ try {
+ return get(
+ key,
+ ctx.kernalContext().job().currentTaskName(),
+ deserializeBinary,
+ needVer);
+ }
+ catch (IgniteConsistencyViolationException e) {
+ repairAsync(key, ctx.operationContextPerCall(), false).get();
- return get0(key, taskName, deserializeBinary, needVer);
+ return repairableGet(key, deserializeBinary, needVer);
+ }
+ catch (IgniteException e) {
+ if (e.getCause(IgniteCheckedException.class) != null)
+ throw e.getCause(IgniteCheckedException.class);
+ else
+ throw e;
+ }
}
/**
@@ -4747,29 +4832,21 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @return Cached value.
* @throws IgniteCheckedException If failed.
*/
- protected V get0(
+ protected V get(
final K key,
String taskName,
boolean deserializeBinary,
boolean needVer) throws IgniteCheckedException {
checkJta();
- try {
- return getAsync(key,
- !ctx.config().isReadFromBackup(),
- /*skip tx*/false,
- null,
- taskName,
- deserializeBinary,
- /*skip vals*/false,
- needVer).get();
- }
- catch (IgniteException e) {
- if (e.getCause(IgniteCheckedException.class) != null)
- throw e.getCause(IgniteCheckedException.class);
- else
- throw e;
- }
+ return getAsync(key,
+ !ctx.config().isReadFromBackup(),
+ /*skip tx*/false,
+ null,
+ taskName,
+ deserializeBinary,
+ /*skip vals*/false,
+ needVer).get();
}
/**
@@ -4778,7 +4855,11 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param needVer Need version.
* @return Read operation future.
*/
- public final IgniteInternalFuture<V> getAsync(final K key, boolean deserializeBinary, final boolean needVer) {
+ public final IgniteInternalFuture<V> repairableGetAsync(
+ final K key,
+ boolean deserializeBinary,
+ final boolean needVer,
+ boolean readRepair) {
try {
checkJta();
}
@@ -4786,16 +4867,25 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
return new GridFinishedFuture<>(e);
}
- String taskName = ctx.kernalContext().job().currentTaskName();
-
- return getAsync(key,
+ IgniteInternalFuture<V> fut = getAsync(key,
!ctx.config().isReadFromBackup(),
/*skip tx*/false,
null,
- taskName,
+ ctx.kernalContext().job().currentTaskName(),
deserializeBinary,
/*skip vals*/false,
needVer);
+
+ if (readRepair) {
+ CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ return getWithRepairAsync(
+ fut,
+ () -> repairAsync(key, opCtx, false),
+ () -> repairableGetAsync(key, deserializeBinary, needVer, readRepair));
+ }
+
+ return fut;
}
/**
@@ -4805,48 +4895,216 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @return Map of cached values.
* @throws IgniteCheckedException If read failed.
*/
- protected Map<K, V> getAll0(Collection<? extends K> keys, boolean deserializeBinary,
- boolean needVer) throws IgniteCheckedException {
- checkJta();
+ protected Map<K, V> repairableGetAll(
+ Collection<? extends K> keys,
+ boolean deserializeBinary,
+ boolean needVer,
+ boolean recovery,
+ boolean readRepair) throws IgniteCheckedException {
+ try {
+ return getAll(keys, deserializeBinary, needVer, recovery, readRepair);
+ }
+ catch (IgniteConsistencyViolationException e) {
+ repairAsync(keys, ctx.operationContextPerCall(), false).get();
- String taskName = ctx.kernalContext().job().currentTaskName();
+ return repairableGetAll(keys, deserializeBinary, needVer, recovery, readRepair);
+ }
+ }
- CacheOperationContext opCtx = ctx.operationContextPerCall();
+ /**
+ * @param keys Keys.
+ * @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
+ * @param recovery Recovery flag.
+ * @param readRepair Read repair flag.
+ * @return Map of cached values.
+ * @throws IgniteCheckedException If read failed.
+ */
+ protected Map<K, V> getAll(
+ Collection<? extends K> keys,
+ boolean deserializeBinary,
+ boolean needVer,
+ boolean recovery,
+ boolean readRepair) throws IgniteCheckedException {
+ checkJta();
return getAllAsync(keys,
!ctx.config().isReadFromBackup(),
/*skip tx*/false,
/*subject id*/null,
- taskName,
+ ctx.kernalContext().job().currentTaskName(),
deserializeBinary,
- opCtx != null && opCtx.recovery(),
+ recovery,
+ readRepair,
/*skip vals*/false,
needVer).get();
}
/**
* @param keys Keys.
- * @param deserializeBinary Deserialize binary flag.
+ * @param forcePrimary Force primary.
+ * @param skipTx Skip tx.
+ * @param subjId Subj Id.
+ * @param taskName Task name.
+ * @param deserializeBinary Deserialize binary.
+ * @param recovery Recovery mode flag.
+ * @param skipVals Skip values.
* @param needVer Need version.
- * @return Read future.
+ * @return Future for the get operation.
+ * @see GridCacheAdapter#getAllAsync(Collection)
*/
- public IgniteInternalFuture<Map<K, V>> getAllAsync(
+ public IgniteInternalFuture<Map<K, V>> repairableGetAllAsync(
@Nullable Collection<? extends K> keys,
+ boolean forcePrimary,
+ boolean skipTx,
+ @Nullable UUID subjId,
+ String taskName,
boolean deserializeBinary,
boolean recovery,
- boolean needVer
+ boolean readRepair,
+ boolean skipVals,
+ final boolean needVer
) {
- String taskName = ctx.kernalContext().job().currentTaskName();
-
- return getAllAsync(keys,
- !ctx.config().isReadFromBackup(),
- /*skip tx*/false,
- /*subject id*/null,
+ IgniteInternalFuture<Map<K, V>> fut = getAllAsync(
+ keys,
+ forcePrimary,
+ skipTx,
+ subjId,
taskName,
deserializeBinary,
recovery,
- /*skip vals*/false,
+ readRepair,
+ skipVals,
needVer);
+
+ if (readRepair) {
+ CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ return getWithRepairAsync(
+ fut,
+ () -> repairAsync(keys, opCtx, skipVals),
+ () -> repairableGetAllAsync(
+ keys,
+ forcePrimary,
+ skipTx,
+ subjId,
+ taskName,
+ deserializeBinary,
+ recovery,
+ readRepair,
+ skipVals,
+ needVer));
+ }
+
+ return fut;
+ }
+
+ /**
+ * Performs repair and retries get if necessary.
+ * @param orig Original get future.
+ * @param repair Repair callback, used in case of inconcstency.
+ * @param retry Callback to original method to retry operation after repair.
+ */
+ private <R> IgniteInternalFuture<R> getWithRepairAsync(
+ IgniteInternalFuture<R> orig,
+ Supplier<IgniteInternalFuture<Void>> repair,
+ Supplier<IgniteInternalFuture<R>> retry) {
+ final GridNearTxLocal tx = checkCurrentTx();
+ final CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+ GridFutureAdapter<R> fut = new GridFutureAdapter<>();
+
+ orig.listen((f) -> {
+ try {
+ fut.onDone(f.get());
+ }
+ catch (IgniteConsistencyViolationException e1) {
+ repair.get().listen((repFut) -> {
+ if (repFut.error() != null)
+ fut.onDone(repFut.error());
+ else {
+ CacheOperationContext prevOpCtx = ctx.operationContextPerCall();
+
+ IgniteInternalTx prevTx = ctx.tm().tx(tx); // Within the original tx.
+ ctx.operationContextPerCall(opCtx); // With the same operation context.
+
+ try {
+ fut.onDone(retry.get().get());
+ }
+ catch (IgniteCheckedException e2) {
+ fut.onDone(e2);
+ }
+ finally {
+ ctx.tm().tx(prevTx);
+ ctx.operationContextPerCall(prevOpCtx);
+ }
+ }
+ });
+ }
+ catch (IgniteCheckedException e1) {
+ fut.onDone(e1);
+ }
+ });
+
+ return fut;
+ }
+
+ /**
+ * Checks and repairs entries across the topology.
+ */
+ protected IgniteInternalFuture<Void> repairAsync(
+ Collection<? extends K> keys,
+ final CacheOperationContext opCtx,
+ boolean skipVals) {
+ GridCompoundFuture fut = new GridCompoundFuture();
+
+ for (K key : keys)
+ fut.add(repairAsync(key, opCtx, skipVals));
+
+ fut.markInitialized();
+
+ return fut;
+ }
+
+ /**
+ * Checks and repairs entry across the topology.
+ */
+ protected IgniteInternalFuture<Void> repairAsync(
+ final K key,
+ final CacheOperationContext opCtx,
+ boolean skipVals) {
+ assert ctx.transactional();
+
+ final GridNearTxLocal orig = checkCurrentTx();
+
+ // Pessimistic non-read-committed 'get' should be fixed inside it's own tx, the only exception is 'contains'.
+ assert orig == null || orig.optimistic() || orig.readCommitted() || /*contains*/ skipVals;
+
+ // Async check and recover if necessary.
+ return ctx.kernalContext().closure().callLocalSafe(new Callable<Void>() {
+ @Override public Void call() throws IgniteCheckedException {
+ CacheOperationContext prevOpCtx = ctx.operationContextPerCall();
+
+ ctx.operationContextPerCall(opCtx);
+
+ try (Transaction tx = ctx.grid().transactions().txStart(PESSIMISTIC, SERIALIZABLE)) {
+ get(key); // Repair.
+
+ final GridNearTxLocal tx0 = checkCurrentTx();
+
+ final IgniteTxKey txKey = ctx.txKey(ctx.toCacheKeyObject(key));
+
+ // Value was broken, fixed locally and should be spread across the topology.
+ if (tx0.txState().hasWriteKey(txKey))
+ tx.commit();
+
+ return null;
+ }
+ finally {
+ ctx.operationContextPerCall(prevOpCtx);
+ }
+ }
+ });
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 94eb857..6fd4269 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -278,7 +278,16 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
@Override public GridCacheProxyImpl<K, V> forSubjectId(UUID subjId) {
return new GridCacheProxyImpl<>(ctx, delegate,
opCtx != null ? opCtx.forSubjectId(subjId) :
- new CacheOperationContext(false, subjId, false, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX));
+ new CacheOperationContext(
+ false,
+ subjId,
+ false,
+ null,
+ false,
+ null,
+ false,
+ false,
+ DFLT_ALLOW_ATOMIC_OPS_IN_TX));
}
/** {@inheritDoc} */
@@ -291,7 +300,16 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
return new GridCacheProxyImpl<>(ctx, delegate,
opCtx != null ? opCtx.setSkipStore(skipStore) :
- new CacheOperationContext(true, null, false, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX));
+ new CacheOperationContext(
+ true,
+ null,
+ false,
+ null,
+ false,
+ null,
+ false,
+ false,
+ DFLT_ALLOW_ATOMIC_OPS_IN_TX));
}
finally {
gate.leave(prev);
@@ -306,7 +324,15 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx,
(GridCacheAdapter<K1, V1>)delegate,
opCtx != null ? opCtx.keepBinary() :
- new CacheOperationContext(false, null, true, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX));
+ new CacheOperationContext(false,
+ null,
+ true,
+ null,
+ false,
+ null,
+ false,
+ false,
+ DFLT_ALLOW_ATOMIC_OPS_IN_TX));
}
/** {@inheritDoc} */
@@ -1572,7 +1598,16 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
try {
return new GridCacheProxyImpl<>(ctx, delegate,
opCtx != null ? opCtx.withExpiryPolicy(plc) :
- new CacheOperationContext(false, null, false, plc, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX));
+ new CacheOperationContext(
+ false,
+ null,
+ false,
+ plc,
+ false,
+ null,
+ false,
+ false,
+ DFLT_ALLOW_ATOMIC_OPS_IN_TX));
}
finally {
gate.leave(prev);
@@ -1585,7 +1620,16 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
try {
return new GridCacheProxyImpl<>(ctx, delegate,
- new CacheOperationContext(false, null, false, null, true, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX));
+ new CacheOperationContext(
+ false,
+ null,
+ false,
+ null,
+ true,
+ null,
+ false,
+ false,
+ DFLT_ALLOW_ATOMIC_OPS_IN_TX));
}
finally {
gate.leave(prev);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index afcd60e..6c9a62a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -365,6 +365,11 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
}
/** {@inheritDoc} */
+ @Override public IgniteCache<K, V> withReadRepair() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
@Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
GridCacheContext<K, V> ctx = getContextSafe();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index dda54ab..31adc06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -762,6 +762,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
String taskName,
boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
boolean skipVals,
boolean needVer
) {
@@ -775,6 +776,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
taskName,
deserializeBinary,
opCtx != null && opCtx.recovery(),
+ readRepair,
forcePrimary,
null,
skipVals,
@@ -816,6 +818,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
skipVals,
/*keep cache objects*/true,
recovery,
+ false,
/*need version*/true,
txLbl,
mvccSnapshot);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 39984b5..6ce1863 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -58,13 +58,15 @@ import org.jetbrains.annotations.Nullable;
* Colocated get future.
*/
public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAdapter<K, V> {
-
/** Transaction label. */
protected final String txLbl;
/** */
protected final MvccSnapshot mvccSnapshot;
+ /** Explicit predefined single mapping (backup or primary). */
+ protected final ClusterNode affNode;
+
/**
* @param cctx Context.
* @param keys Keys.
@@ -96,7 +98,8 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
boolean needVer,
boolean keepCacheObjects,
@Nullable String txLbl,
- @Nullable MvccSnapshot mvccSnapshot
+ @Nullable MvccSnapshot mvccSnapshot,
+ ClusterNode affNode
) {
super(
cctx,
@@ -116,8 +119,8 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
assert (mvccSnapshot == null) == !cctx.mvccEnabled();
this.mvccSnapshot = mvccSnapshot;
-
this.txLbl = txLbl;
+ this.affNode = affNode;
initLogger(GridPartitionedGetFuture.class);
}
@@ -323,25 +326,37 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
Map<ClusterNode, LinkedHashMap<KeyCacheObject, Boolean>> missedNodesToKeysMapping,
Map<K, V> locVals
) {
+ ClusterNode node;
+
int part = cctx.affinity().partition(key);
+ Set<ClusterNode> invalidNodeSet = getInvalidNodes(part, topVer);
+
List<ClusterNode> affNodes = cctx.affinity().nodesByPartition(part, topVer);
- // Failed if none affinity node found.
- if (affNodes.isEmpty()) {
- onDone(serverNotFoundError(part, topVer));
+ if (affNode != null) {
+ if (invalidNodeSet.contains(affNode) || !cctx.discovery().alive(affNode)) {
+ onDone(Collections.emptyMap());
- return false;
+ return false;
+ }
+
+ node = affNodes.contains(affNode) ? affNode : null;
}
+ else {
+ // Failed if none affinity node found.
+ if (affNodes.isEmpty()) {
+ onDone(serverNotFoundError(part, topVer));
- // Try to read key localy if we can.
- if (tryLocalGet(key, part, topVer, affNodes, locVals))
- return false;
+ return false;
+ }
- Set<ClusterNode> invalidNodeSet = getInvalidNodes(part, topVer);
+ // Try to read key localy if we can.
+ if (tryLocalGet(key, part, topVer, affNodes, locVals))
+ return false;
- // Get remote node for request for this key.
- ClusterNode node = cctx.selectAffinityNodeBalanced(affNodes, invalidNodeSet, part, canRemap);
+ node = cctx.selectAffinityNodeBalanced(affNodes, invalidNodeSet, part, canRemap);
+ }
// Failed if none remote node found.
if (node == null) {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index b8e45c9..4c47c0c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -83,6 +83,8 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetR
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
@@ -471,6 +473,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final ExpiryPolicy expiryPlc = skipVals ? null : opCtx != null ? opCtx.expiry() : null;
final boolean skipStore = opCtx != null && opCtx.skipStore();
final boolean recovery = opCtx != null && opCtx.recovery();
+ final boolean readRepair = opCtx != null && opCtx.readRepair();
return asyncOp(new CO<IgniteInternalFuture<V>>() {
@Override public IgniteInternalFuture<V> apply() {
@@ -480,6 +483,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
taskName,
deserializeBinary,
recovery,
+ readRepair,
expiryPlc,
skipVals,
skipStore,
@@ -489,16 +493,19 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
/** {@inheritDoc} */
- @Override protected Map<K, V> getAll0(Collection<? extends K> keys, boolean deserializeBinary, boolean needVer)
- throws IgniteCheckedException {
- CacheOperationContext opCtx = ctx.operationContextPerCall();
-
+ @Override protected Map<K, V> getAll(
+ Collection<? extends K> keys,
+ boolean deserializeBinary,
+ boolean needVer,
+ boolean recovery,
+ boolean readRepair) throws IgniteCheckedException {
return getAllAsyncInternal(keys,
!ctx.config().isReadFromBackup(),
null,
ctx.kernalContext().job().currentTaskName(),
deserializeBinary,
- opCtx != null && opCtx.recovery(),
+ recovery,
+ readRepair,
false,
needVer,
false).get();
@@ -513,6 +520,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final String taskName,
final boolean deserializeBinary,
final boolean recovery,
+ final boolean readRepair,
final boolean skipVals,
final boolean needVer
) {
@@ -522,6 +530,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
taskName,
deserializeBinary,
recovery,
+ readRepair,
skipVals,
needVer,
true);
@@ -533,6 +542,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
* @param subjId Subject ID.
* @param taskName Task name.
* @param deserializeBinary Deserialize binary flag.
+ * @param readRepair Read Repair flag.
* @param skipVals Skip values flag.
* @param needVer Need version flag.
* @param asyncOp Async operation flag.
@@ -545,6 +555,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final String taskName,
final boolean deserializeBinary,
final boolean recovery,
+ final boolean readRepair,
final boolean skipVals,
final boolean needVer,
boolean asyncOp
@@ -576,6 +587,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
taskName,
deserializeBinary,
recovery,
+ readRepair,
expiryPlc,
skipVals,
skipStore,
@@ -590,6 +602,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
taskName,
deserializeBinary,
recovery,
+ readRepair,
expiryPlc,
skipVals,
skipStore,
@@ -1390,6 +1403,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
* @param subjId Subject ID.
* @param taskName Task name.
* @param deserializeBinary Deserialize binary flag.
+ * @param readRepair Read Repair flag.
* @param expiryPlc Expiry policy.
* @param skipVals Skip values flag.
* @param skipStore Skip store flag.
@@ -1402,6 +1416,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
String taskName,
boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
@Nullable ExpiryPolicy expiryPlc,
boolean skipVals,
boolean skipStore,
@@ -1411,6 +1426,21 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
IgniteCacheExpiryPolicy expiry = skipVals ? null : expiryPolicy(expiryPlc);
+ if (readRepair) {
+ return new GridNearReadRepairCheckOnlyFuture(
+ ctx,
+ Collections.singleton(ctx.toCacheKeyObject(key)),
+ !skipStore,
+ taskName,
+ deserializeBinary,
+ recovery,
+ expiry,
+ skipVals,
+ needVer,
+ false,
+ null).single();
+ }
+
GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx,
key,
topVer,
@@ -1452,6 +1482,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
String taskName,
boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
@Nullable ExpiryPolicy expiryPlc,
boolean skipVals,
boolean skipStore,
@@ -1463,6 +1494,21 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final boolean evt = !skipVals;
+ if (readRepair) {
+ return new GridNearReadRepairCheckOnlyFuture(
+ ctx,
+ ctx.cacheKeysView(keys),
+ !skipStore,
+ taskName,
+ deserializeBinary,
+ recovery,
+ expiry,
+ skipVals,
+ needVer,
+ false,
+ null).multi();
+ }
+
// Optimisation: try to resolve value locally and escape 'get future' creation.
if (!forcePrimary && ctx.affinityNode()) {
try {
@@ -1632,6 +1678,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
needVer,
false,
null,
+ null,
null);
fut.init(topVer);
@@ -1690,6 +1737,20 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
}
+ /** {@inheritDoc} */
+ @Override protected IgniteInternalFuture<Void> repairAsync(Collection<? extends K> keys,
+ final CacheOperationContext opCtx, boolean skipVals) {
+ return new GridFinishedFuture<>(
+ new IgniteConsistencyViolationException("Consistency violation detected during Read Repair procedure."));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteInternalFuture<Void> repairAsync(final K key, final CacheOperationContext opCtx,
+ boolean skipVals) {
+ return new GridFinishedFuture<>(
+ new IgniteConsistencyViolationException("Consistency violation detected during Read Repair procedure."));
+ }
+
/**
* @param nodeId Node ID.
* @param req Update request.
@@ -1985,7 +2046,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
boolean hasNear = req.nearCache();
// Assign next version for update inside entries lock.
- GridCacheVersion ver = ctx.versions().next(top.readyTopologyVersion());
+ GridCacheVersion ver = dhtUpdRes.dhtFuture() != null /*retry*/ ?
+ dhtUpdRes.dhtFuture().writeVer : ctx.versions().next(top.readyTopologyVersion());
if (hasNear)
res.nearVersion(ver);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 1c60aae..a8a27d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -59,6 +59,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSing
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture;
import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
@@ -194,6 +195,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
final CacheOperationContext opCtx = ctx.operationContextPerCall();
final boolean recovery = opCtx != null && opCtx.recovery();
+ final boolean readRepair = opCtx != null && opCtx.readRepair();
// Get operation bypass Tx in Mvcc mode.
if (!ctx.mvccEnabled() && tx != null && !tx.implicit() && !skipTx) {
@@ -207,6 +209,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
false,
opCtx != null && opCtx.skipStore(),
recovery,
+ readRepair,
needVer);
return fut.chain(new CX1<IgniteInternalFuture<Map<Object, Object>>, V>() {
@@ -260,6 +263,21 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
else
topVer = ctx.affinity().affinityTopologyVersion();
+ if (readRepair) {
+ return new GridNearReadRepairCheckOnlyFuture(
+ ctx,
+ Collections.singleton(ctx.toCacheKeyObject(key)),
+ opCtx == null || !opCtx.skipStore(),
+ taskName,
+ deserializeBinary,
+ recovery,
+ skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
+ skipVals,
+ needVer,
+ false,
+ tx).single();
+ }
+
GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx,
ctx.toCacheKeyObject(key),
topVer,
@@ -301,6 +319,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
String taskName,
final boolean deserializeBinary,
final boolean recovery,
+ final boolean readRepair,
final boolean skipVals,
final boolean needVer
) {
@@ -329,6 +348,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
false,
opCtx != null && opCtx.skipStore(),
recovery,
+ readRepair,
needVer);
}
}, opCtx, /*retry*/false);
@@ -365,6 +385,21 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
else
topVer = ctx.affinity().affinityTopologyVersion();
+ if (readRepair) {
+ return new GridNearReadRepairCheckOnlyFuture(
+ ctx,
+ ctx.cacheKeysView(keys),
+ opCtx == null || !opCtx.skipStore(),
+ taskName,
+ deserializeBinary,
+ recovery,
+ skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
+ skipVals,
+ needVer,
+ false,
+ tx).multi();
+ }
+
IgniteInternalFuture<Map<K, V>> fut = loadAsync(
ctx.cacheKeysView(keys),
opCtx == null || !opCtx.skipStore(),
@@ -669,7 +704,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
needVer,
keepCacheObj,
txLbl,
- mvccSnapshot);
+ mvccSnapshot,
+ null);
fut.init(topVer);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index 211ae12..a9b34a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -41,12 +41,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
-import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicAbstractUpdateRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicNearResponse;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -408,6 +408,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
String taskName,
boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
boolean skipVals,
boolean needVer
) {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index b978223..151aeb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -121,6 +121,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
String taskName,
final boolean deserializeBinary,
final boolean recovery,
+ final boolean readRepair,
final boolean skipVals,
final boolean needVer
) {
@@ -149,6 +150,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
false,
skipStore,
recovery,
+ readRepair,
needVer);
}
}, opCtx, /*retry*/false);
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 59bbbe5..593dd9e 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
@@ -61,6 +61,9 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLoca
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridInvokeValue;
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairFuture;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator;
import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorChangeAware;
@@ -2136,6 +2139,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
* @param skipVals Skip values flag.
* @param keepCacheObjects Keep cache objects
* @param skipStore Skip store flag.
+ * @param readRepair Read Repair flag.
* @return Future for this get.
*/
@SuppressWarnings("unchecked")
@@ -2148,6 +2152,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
final boolean keepCacheObjects,
final boolean skipStore,
final boolean recovery,
+ final boolean readRepair,
final boolean needVer) {
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -2192,6 +2197,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
keepCacheObjects,
skipStore,
recovery,
+ readRepair,
needVer);
}
catch (IgniteCheckedException e) {
@@ -2357,11 +2363,71 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
keepCacheObjects,
skipStore,
recovery,
+ readRepair,
needVer,
expiryPlc0);
}
- return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
+ if (readRepair) {
+ return new GridNearReadRepairFuture(
+ topVer != null ? topVer : topologyVersion(),
+ cacheCtx,
+ keys,
+ !skipStore,
+ taskName,
+ deserializeBinary,
+ recovery,
+ cacheCtx.cache().expiryPolicy(expiryPlc0),
+ GridNearTxLocal.this)
+ .chain((fut) -> {
+ try {
+ // For every fixed entry.
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.get().entrySet()) {
+ EntryGetResult getRes = entry.getValue();
+
+ enlistWrite(
+ cacheCtx,
+ entryTopVer,
+ entry.getKey(),
+ getRes.value(),
+ expiryPlc0,
+ null,
+ null,
+ false,
+ false,
+ null,
+ null,
+ skipStore,
+ false,
+ !deserializeBinary,
+ recovery,
+ null);
+
+ // Rewriting fixed, initially filled by explicit lock operation.
+ cacheCtx.addResult(retMap,
+ entry.getKey(),
+ getRes.value(),
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ getRes.version(),
+ 0,
+ 0,
+ needVer);
+ }
+
+ return Collections.emptyMap();
+ }
+ catch (Exception e) {
+ throw new GridClosureException(e);
+ }
+ }
+ );
+ }
+
+ return new GridFinishedFuture<>(Collections.emptyMap());
}
};
@@ -2433,6 +2499,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
keepCacheObjects,
skipStore,
recovery,
+ readRepair,
needVer,
expiryPlc);
}
@@ -2476,6 +2543,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
boolean keepCacheObjects,
boolean skipStore,
boolean recovery,
+ boolean readRepair,
final boolean needVer
) throws IgniteCheckedException {
assert !F.isEmpty(keys);
@@ -2647,7 +2715,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
GridCacheVersion readVer = null;
EntryGetResult getRes = null;
- if (!pessimistic() || readCommitted() && !skipVals) {
+ if ((!pessimistic() || (readCommitted() && !skipVals)) && !readRepair) {
IgniteCacheExpiryPolicy accessPlc =
optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
@@ -2863,6 +2931,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
needReadVer,
keepBinary,
recovery,
+ false,
expiryPlc,
c);
}
@@ -2957,6 +3026,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
* @param skipVals Skip values flag.
* @param needVer If {@code true} version is required for loaded values.
* @param c Closure to be applied for loaded values.
+ * @param readRepair Read Repair flag.
* @param expiryPlc Expiry policy.
* @return Future with {@code True} value if loading took place.
*/
@@ -2970,6 +3040,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
final boolean needVer,
boolean keepBinary,
boolean recovery,
+ boolean readRepair,
final ExpiryPolicy expiryPlc,
final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c
) {
@@ -3004,6 +3075,42 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
});
}
else if (cacheCtx.isColocated()) {
+ if (readRepair) {
+ return new GridNearReadRepairCheckOnlyFuture(
+ cacheCtx,
+ keys,
+ readThrough,
+ taskName,
+ false,
+ recovery,
+ expiryPlc0,
+ skipVals,
+ needVer,
+ true,
+ this)
+ .multi()
+ .chain((fut) -> {
+ try {
+ Map<Object, Object> map = fut.get();
+
+ processLoaded(map, keys, needVer, c);
+
+ return null;
+ }
+ catch (IgniteConsistencyViolationException e) {
+ for (KeyCacheObject key : keys)
+ txState().removeEntry(cacheCtx.txKey(key)); // Will be recreated after repair.
+
+ throw new GridClosureException(e);
+ }
+ catch (Exception e) {
+ setRollbackOnly();
+
+ throw new GridClosureException(e);
+ }
+ });
+ }
+
if (keys.size() == 1) {
final KeyCacheObject key = F.first(keys);
@@ -3233,6 +3340,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
return new GridFinishedFuture<>();
}
catch (IgniteCheckedException e) {
+ setRollbackOnly();
+
return new GridFinishedFuture<>(e);
}
}
@@ -4556,6 +4665,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
* @param skipVals Skip values flag.
* @param keepCacheObjects Keep cache objects flag.
* @param skipStore Skip store flag.
+ * @param readRepair Read Repair flag.
* @param expiryPlc Expiry policy.
* @return Loaded key-value pairs.
*/
@@ -4569,6 +4679,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
final boolean keepCacheObjects,
final boolean skipStore,
final boolean recovery,
+ final boolean readRepair,
final boolean needVer,
final ExpiryPolicy expiryPlc
) {
@@ -4580,11 +4691,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
return new GridEmbeddedFuture<>(
new C2<Void, Exception, Map<K, V>>() {
@Override public Map<K, V> apply(Void v, Exception e) {
- if (e != null) {
- setRollbackOnly();
-
+ if (e != null)
throw new GridClosureException(e);
- }
if (isRollbackOnly()) {
if (timedOut())
@@ -4608,6 +4716,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements GridTimeou
needReadVer,
!deserializeBinary,
recovery,
+ readRepair,
expiryPlc,
new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override public void apply(KeyCacheObject key, Object val, GridCacheVersion loadVer) {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java
new file mode 100644
index 0000000..551f8eb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java
@@ -0,0 +1,221 @@
+/*
+ * 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.distributed.near.consistency;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_NEAR_GET_MAX_REMAPS;
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
+
+/**
+ *
+ */
+public abstract class GridNearReadRepairAbstractFuture extends GridFutureAdapter<Map<KeyCacheObject, EntryGetResult>> {
+ /** Default max remap count value. */
+ public static final int DFLT_MAX_REMAP_CNT = 3;
+
+ /** Maximum number of attempts to remap key to the same primary node. */
+ protected static final int MAX_REMAP_CNT = getInteger(IGNITE_NEAR_GET_MAX_REMAPS, DFLT_MAX_REMAP_CNT);
+
+ /** Remap count updater. */
+ protected static final AtomicIntegerFieldUpdater<GridNearReadRepairAbstractFuture> REMAP_CNT_UPD =
+ AtomicIntegerFieldUpdater.newUpdater(GridNearReadRepairAbstractFuture.class, "remapCnt");
+
+ /** Remap count. */
+ protected volatile int remapCnt;
+
+ /** Affinity node's get futures. */
+ protected final Map<ClusterNode, GridPartitionedGetFuture<KeyCacheObject, EntryGetResult>> futs = new ConcurrentHashMap<>();
+
+ /** Context. */
+ protected final GridCacheContext<KeyCacheObject, EntryGetResult> ctx;
+
+ /** Context. */
+ protected final Collection<KeyCacheObject> keys;
+
+ /** Read through flag. */
+ protected final boolean readThrough;
+
+ /** Task name. */
+ protected final String taskName;
+
+ /** Deserialize binary flag. */
+ protected final boolean deserializeBinary;
+
+ /** Recovery flag. */
+ protected final boolean recovery;
+
+ /** Expiry policy flag. */
+ protected final IgniteCacheExpiryPolicy expiryPlc;
+
+ /** Tx. */
+ protected final IgniteInternalTx tx;
+
+ /** Remap flag. */
+ private final boolean canRemap;
+
+ /** Latest mapped topology version. */
+ private AffinityTopologyVersion topVer;
+
+ /**
+ *
+ */
+ protected GridNearReadRepairAbstractFuture(
+ AffinityTopologyVersion topVer,
+ GridCacheContext<KeyCacheObject, EntryGetResult> ctx,
+ Collection<KeyCacheObject> keys,
+ boolean readThrough,
+ String taskName,
+ boolean deserializeBinary,
+ boolean recovery,
+ IgniteCacheExpiryPolicy expiryPlc,
+ IgniteInternalTx tx) {
+ this.ctx = ctx;
+ this.keys = keys;
+ this.readThrough = readThrough;
+ this.taskName = taskName;
+ this.deserializeBinary = deserializeBinary;
+ this.recovery = recovery;
+ this.expiryPlc = expiryPlc;
+ this.tx = tx;
+
+ canRemap = topVer == null;
+
+ map(canRemap ? ctx.affinity().affinityTopologyVersion() : topVer);
+ }
+
+ /**
+ *
+ */
+ protected synchronized void map(AffinityTopologyVersion topVer) {
+ this.topVer = topVer;
+
+ futs.clear();
+
+ IgniteInternalTx prevTx = ctx.tm().tx(tx); // Within the original tx.
+
+ try {
+ Map<ClusterNode, Collection<KeyCacheObject>> mappings = new HashMap<>();
+
+ for (KeyCacheObject key : keys) {
+ Collection<ClusterNode> nodes = ctx.affinity().nodesByKey(key, topVer);
+
+ for (ClusterNode node : nodes)
+ mappings.computeIfAbsent(node, k -> new HashSet<>()).add(key);
+ }
+
+ for (Map.Entry<ClusterNode, Collection<KeyCacheObject>> mapping : mappings.entrySet()) {
+ ClusterNode node = mapping.getKey();
+
+ GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut =
+ new GridPartitionedGetFuture<>(
+ ctx,
+ mapping.getValue(), // Keys.
+ readThrough,
+ false, // Local get required.
+ tx != null ? tx.subjectId() : null,
+ taskName,
+ deserializeBinary,
+ recovery,
+ expiryPlc,
+ false,
+ true,
+ true,
+ tx != null ? tx.label() : null,
+ tx != null ? tx.mvccSnapshot() : null,
+ node);
+
+ fut.listen(this::onResult);
+
+ futs.put(mapping.getKey(), fut);
+ }
+
+ for (GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut : futs.values())
+ fut.init(topVer);
+
+ if (futs.isEmpty())
+ onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
+ "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + ctx.name() + ']'));
+ }
+ finally {
+ ctx.tm().tx(prevTx);
+ }
+ }
+
+ /**
+ *
+ */
+ protected synchronized void onResult(IgniteInternalFuture<Map<KeyCacheObject, EntryGetResult>> finished) {
+ if (isDone() || /*remapping*/ topVer == null)
+ return;
+
+ if (finished.error() != null) {
+ if (finished.error() instanceof ClusterTopologyServerNotFoundException) {
+ if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT) {
+ onDone(new ClusterTopologyCheckedException("Failed to remap keys to a new nodes after " +
+ MAX_REMAP_CNT + " attempts (keys got remapped to the same node) ]"));
+ }
+ else if (!canRemap)
+ map(topVer);
+ else {
+ long maxTopVer = Math.max(topVer.topologyVersion() + 1, ctx.discovery().topologyVersion());
+
+ AffinityTopologyVersion awaitTopVer = new AffinityTopologyVersion(maxTopVer);
+
+ topVer = null;
+
+ ctx.shared().exchange().affinityReadyFuture(awaitTopVer)
+ .listen((f) -> map(awaitTopVer));
+ }
+ }
+ else
+ onDone(finished.error());
+
+ return;
+ }
+
+ for (IgniteInternalFuture fut : futs.values()) {
+ if (!fut.isDone() || fut.error() != null)
+ return;
+ }
+
+ reduce();
+ }
+
+ /**
+ * Reduces fut's results.
+ */
+ protected abstract void reduce();
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairCheckOnlyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairCheckOnlyFuture.java
new file mode 100644
index 0000000..0388e3f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairCheckOnlyFuture.java
@@ -0,0 +1,176 @@
+/*
+ * 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.distributed.near.consistency;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.lang.GridClosureException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
+
+/**
+ * Checks data consistency. Checks that each backup value equals to primary value.
+ */
+public class GridNearReadRepairCheckOnlyFuture extends GridNearReadRepairAbstractFuture {
+ /** Skip values. */
+ private final boolean skipVals;
+
+ /** Need version. */
+ private final boolean needVer;
+
+ /** Keep cache objects. */
+ private boolean keepCacheObjects;
+
+ /**
+ *
+ */
+ public GridNearReadRepairCheckOnlyFuture(
+ GridCacheContext ctx,
+ Collection<KeyCacheObject> keys,
+ boolean readThrough,
+ String taskName,
+ boolean deserializeBinary,
+ boolean recovery,
+ IgniteCacheExpiryPolicy expiryPlc,
+ boolean skipVals,
+ boolean needVer,
+ boolean keepCacheObjects,
+ IgniteInternalTx tx) {
+ super(null,
+ ctx,
+ keys,
+ readThrough,
+ taskName,
+ deserializeBinary,
+ recovery,
+ expiryPlc,
+ tx);
+
+ this.skipVals = skipVals;
+ this.needVer = needVer;
+ this.keepCacheObjects = keepCacheObjects;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void reduce() {
+ Map<KeyCacheObject, EntryGetResult> map = new HashMap<>();
+
+ for (GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut : futs.values()) {
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.result().entrySet()) {
+ KeyCacheObject key = entry.getKey();
+ EntryGetResult candidate = entry.getValue();
+ EntryGetResult old = map.get(key);
+
+ if (old != null && old.version().compareTo(candidate.version()) != 0) {
+ if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT)
+ onDone(new IgniteConsistencyViolationException("Distributed cache consistency violation detected."));
+ else
+ map(ctx.affinity().affinityTopologyVersion()); // Rechecking possible "false positive" case.
+
+ return;
+ }
+
+ map.put(key, candidate);
+ }
+ }
+
+ onDone(map);
+ }
+
+ /**
+ * Produces 1 entry's value.
+ */
+ public <K, V> IgniteInternalFuture<V> single() {
+ return chain((fut) -> {
+ try {
+ final Map<K, V> map = new IgniteBiTuple<>();
+
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.get().entrySet()) {
+ EntryGetResult getRes = entry.getValue();
+
+ ctx.addResult(map,
+ entry.getKey(),
+ getRes.value(),
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ getRes.version(),
+ 0,
+ 0,
+ needVer);
+ }
+
+ if (skipVals) {
+ Boolean val = map.isEmpty() ? false : (Boolean)F.firstValue(map);
+
+ return (V)(val);
+ }
+ else
+ return F.firstValue(map);
+ }
+ catch (IgniteCheckedException e) {
+ throw new GridClosureException(e);
+ }
+ });
+ }
+
+ /**
+ * Produces entry map.
+ */
+ public <K, V> IgniteInternalFuture<Map<K, V>> multi() {
+ return chain((fut) -> {
+ try {
+ final Map<K, V> map = U.newHashMap(keys.size());
+
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.get().entrySet()) {
+ EntryGetResult getRes = entry.getValue();
+
+ ctx.addResult(map,
+ entry.getKey(),
+ getRes.value(),
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ getRes.version(),
+ 0,
+ 0,
+ needVer);
+ }
+
+ return map;
+ }
+ catch (Exception e) {
+ throw new GridClosureException(e);
+ }
+ });
+ }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairFuture.java
new file mode 100644
index 0000000..35aae3c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairFuture.java
@@ -0,0 +1,166 @@
+/*
+ * 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.distributed.near.consistency;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.events.CacheConsistencyViolationEvent;
+import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+
+import static org.apache.ignite.events.EventType.EVT_CONSISTENCY_VIOLATION;
+
+/**
+ * Checks data consistency. Checks that each affinity node's value equals other's. Prepares recovery data. Records
+ * consistency violation event.
+ */
+public class GridNearReadRepairFuture extends GridNearReadRepairAbstractFuture {
+ /**
+ *
+ */
+ public GridNearReadRepairFuture(
+ AffinityTopologyVersion topVer,
+ GridCacheContext ctx,
+ Collection<KeyCacheObject> keys,
+ boolean readThrough,
+ String taskName,
+ boolean deserializeBinary,
+ boolean recovery,
+ IgniteCacheExpiryPolicy expiryPlc,
+ IgniteInternalTx tx) {
+ super(topVer,
+ ctx,
+ keys,
+ readThrough,
+ taskName,
+ deserializeBinary,
+ recovery,
+ expiryPlc,
+ tx);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void reduce() {
+ Map<KeyCacheObject, EntryGetResult> newestMap = new HashMap<>();
+ Map<KeyCacheObject, EntryGetResult> fixedMap = new HashMap<>();
+
+ for (GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut : futs.values()) {
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.result().entrySet()) {
+ KeyCacheObject key = entry.getKey();
+
+ EntryGetResult candidate = entry.getValue();
+
+ newestMap.putIfAbsent(key, candidate);
+
+ EntryGetResult newest = newestMap.get(key);
+
+ if (newest.version().compareTo(candidate.version()) < 0) {
+ newestMap.put(key, candidate);
+ fixedMap.put(key, candidate);
+ }
+
+ if (newest.version().compareTo(candidate.version()) > 0)
+ fixedMap.put(key, newest);
+ }
+ }
+
+ recordConsistencyViolation(fixedMap);
+
+ onDone(fixedMap);
+ }
+
+ /**
+ * @param fixedRaw Fixed map.
+ */
+ private void recordConsistencyViolation(Map<KeyCacheObject, EntryGetResult> fixedRaw) {
+ GridEventStorageManager evtMgr = ctx.gridEvents();
+
+ if (!evtMgr.isRecordable(EVT_CONSISTENCY_VIOLATION))
+ return;
+
+ if (fixedRaw.isEmpty())
+ return;
+
+ Map<Object, Object> fixedMap = new HashMap<>();
+
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fixedRaw.entrySet()) {
+ KeyCacheObject key = entry.getKey();
+ CacheObject val = entry.getValue().value();
+
+ ctx.addResult(
+ fixedMap,
+ key,
+ val,
+ false,
+ false,
+ deserializeBinary,
+ false,
+ null,
+ 0,
+ 0);
+ }
+
+ Map<UUID, Map<Object, Object>> originalMap = new HashMap<>();
+
+ for (Map.Entry<ClusterNode, GridPartitionedGetFuture<KeyCacheObject, EntryGetResult>> pair : futs.entrySet()) {
+ ClusterNode node = pair.getKey();
+
+ GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut = pair.getValue();
+
+ for (Map.Entry<KeyCacheObject, EntryGetResult> entry : fut.result().entrySet()) {
+ KeyCacheObject key = entry.getKey();
+
+ if (fixedRaw.containsKey(key)) {
+ CacheObject val = entry.getValue().value();
+
+ originalMap.computeIfAbsent(node.id(), id -> new HashMap<>());
+
+ Map<Object, Object> map = originalMap.get(node.id());
+
+ ctx.addResult(
+ map,
+ key,
+ val,
+ false,
+ false,
+ deserializeBinary,
+ false,
+ null,
+ 0,
+ 0);
+ }
+ }
+ }
+
+ evtMgr.record(new CacheConsistencyViolationEvent(
+ ctx.discovery().localNode(),
+ "Consistency violation fixed.",
+ originalMap,
+ fixedMap));
+ }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
new file mode 100644
index 0000000..db3d448
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.distributed.near.consistency;
+
+import org.apache.ignite.IgniteCheckedException;
+
+/**
+ * Possible consistency violation exception.
+ * Each such case should be rechecked under locks.
+ */
+public class IgniteConsistencyViolationException extends IgniteCheckedException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param msg Message.
+ */
+ public IgniteConsistencyViolationException(String msg) {
+ super(msg);
+ }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index f46e90f..c62b1df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -292,7 +292,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
}
/** {@inheritDoc} */
- @Override protected V get0(
+ @Override protected V get(
final K key,
String taskName,
boolean deserializeBinary,
@@ -310,8 +310,12 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
}
/** {@inheritDoc} */
- @Override public final Map<K, V> getAll0(Collection<? extends K> keys, boolean deserializeBinary, boolean needVer)
- throws IgniteCheckedException {
+ @Override public final Map<K, V> getAll(
+ Collection<? extends K> keys,
+ boolean deserializeBinary,
+ boolean needVer,
+ boolean recovery,
+ boolean readRepair) throws IgniteCheckedException {
A.notNull(keys, "keys");
String taskName = ctx.kernalContext().job().currentTaskName();
@@ -334,6 +338,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
final String taskName,
final boolean deserializeBinary,
boolean recovery,
+ boolean readRepair,
final boolean skipVals,
final boolean needVer
) {
@@ -535,6 +540,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
taskName,
deserializeBinary,
opCtx != null && opCtx.recovery(),
+ false,
/*force primary*/false,
expiry,
skipVals,
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index b8d596c..b17a9b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -668,7 +668,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
/**
* @return {@code True} if has previous value explicitly set.
*/
- boolean hasPreviousValue() {
+ public boolean hasPreviousValue() {
return prevVal.hasValue();
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
index 4978320..4206191 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
@@ -303,6 +303,11 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter {
}
/** {@inheritDoc} */
+ @Override public void removeEntry(IgniteTxKey key) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
@Override public void seal() {
// No-op.
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java
index e007f90..5ed67d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java
@@ -30,6 +30,11 @@ public interface IgniteTxLocalState extends IgniteTxState {
public void addEntry(IgniteTxEntry entry);
/**
+ * @param key Key.
+ */
+ public void removeEntry(IgniteTxKey key);
+
+ /**
* @param txSize Transaction size.
* @return {@code True} if transaction was successfully started.
*/
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 9a00533..3e994ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -797,6 +797,16 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * Sets transaction for current thread.
+ * @return Previously associated transaction.
+ */
+ public IgniteInternalTx tx(IgniteInternalTx tx) {
+ long key = Thread.currentThread().getId();
+
+ return tx == null ? threadMap.remove(key) : threadMap.put(key, tx);
+ }
+
+ /**
* @return Transaction for current thread.
*/
public <T> T tx() {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
index 402085c..bba2e63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
@@ -487,6 +487,11 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter {
}
/** {@inheritDoc} */
+ @Override public synchronized void removeEntry(IgniteTxKey key) {
+ txMap.remove(key);
+ }
+
+ /** {@inheritDoc} */
@Override public void seal() {
if (readView != null)
readView.seal();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
index 7ed29cb..82faefe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
@@ -281,7 +281,7 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter {
topVer += (gridStartTime - TOP_VER_BASE_TIME) / 1000;
}
- int locNodeOrder = (int)cctx.localNode().order();
+ int locNodeOrder = forLoad ? 0 : (int)cctx.localNode().order();
long ord = forLoad ? loadOrder.incrementAndGet() : order.incrementAndGet();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
index e3a77c5..daf7b04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
@@ -442,6 +442,7 @@ public abstract class GridCacheQueueAdapter<T> extends AbstractCollection<T> imp
false,
null,
false,
+ false,
DFLT_ALLOW_ATOMIC_OPS_IN_TX)
: opCtx.keepBinary();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index 45465be..04e05d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -17,12 +17,18 @@
package org.apache.ignite.internal.util.future;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.C1;
@@ -33,12 +39,6 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteReducer;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-
/**
* Future composed of multiple inner futures.
*/
@@ -111,7 +111,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> implements Ig
}
}
catch (IgniteTxOptimisticCheckedException | IgniteFutureCancelledCheckedException |
- ClusterTopologyCheckedException e) {
+ ClusterTopologyCheckedException | IgniteConsistencyViolationException e) {
if (!processFailure(e, fut))
onDone(e);
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractFullSetReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractFullSetReadRepairTest.java
new file mode 100644
index 0000000..b55dc77
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractFullSetReadRepairTest.java
@@ -0,0 +1,242 @@
+/*
+ * 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.consistency;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.internal.util.typedef.G;
+import org.junit.Test;
+
+public abstract class AbstractFullSetReadRepairTest extends AbstractReadRepairTest {
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> GET_CHECK_AND_FIX = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean raw = data.raw;
+ boolean async = data.async;
+
+ assert keys.size() == 1;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) { // Once.
+ Integer key = entry.getKey();
+ Integer latest = entry.getValue().latest;
+
+ Integer res =
+ raw ?
+ async ?
+ cache.withReadRepair().getEntryAsync(key).get().getValue() :
+ cache.withReadRepair().getEntry(key).getValue() :
+ async ?
+ cache.withReadRepair().getAsync(key).get() :
+ cache.withReadRepair().get(key);
+
+ assertEquals(latest, res);
+
+ checkEvent(data);
+ }
+ };
+
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> GETALL_CHECK_AND_FIX = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean raw = data.raw;
+ boolean async = data.async;
+
+ assert !keys.isEmpty();
+
+ if (raw) {
+ Collection<CacheEntry<Integer, Integer>> res =
+ async ?
+ cache.withReadRepair().getEntriesAsync(keys).get() :
+ cache.withReadRepair().getEntries(keys);
+
+ for (CacheEntry<Integer, Integer> entry : res)
+ assertEquals(data.data.get(entry.getKey()).latest, entry.getValue());
+ }
+ else {
+ Map<Integer, Integer> res =
+ async ?
+ cache.withReadRepair().getAllAsync(keys).get() :
+ cache.withReadRepair().getAll(keys);
+
+ for (Map.Entry<Integer, Integer> entry : res.entrySet())
+ assertEquals(data.data.get(entry.getKey()).latest, entry.getValue());
+ }
+
+ checkEvent(data);
+ };
+
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> GET_NULL = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean raw = data.raw;
+ boolean async = data.async;
+
+ assert keys.size() == 1;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) { // Once.
+ Integer key = entry.getKey();
+ Integer missed = key * -1; // Negative to gain null.
+
+ Object res =
+ raw ?
+ async ?
+ cache.withReadRepair().getEntryAsync(missed).get() :
+ cache.withReadRepair().getEntry(missed) :
+ async ?
+ cache.withReadRepair().getAsync(missed).get() :
+ cache.withReadRepair().get(missed);
+
+ assertEquals(null, res);
+
+ checkEvent( // Checking on null expectations.
+ new ReadRepairData(
+ cache,
+ Collections.singletonMap(
+ missed,
+ new InconsistentMapping(new HashMap<>(), null, null)),
+ raw,
+ async));
+ }
+ };
+
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> CONTAINS_CHECK_AND_FIX = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean async = data.async;
+
+ assert keys.size() == 1;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) { // Once.
+ Integer key = entry.getKey();
+
+ boolean res = async ?
+ cache.withReadRepair().containsKeyAsync(key).get() :
+ cache.withReadRepair().containsKey(key);
+
+ assertEquals(true, res);
+
+ checkEvent(data);
+ }
+ };
+
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> CONTAINS_ALL_CHECK_AND_FIX = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean async = data.async;
+
+ boolean res = async ?
+ cache.withReadRepair().containsKeysAsync(keys).get() :
+ cache.withReadRepair().containsKeys(keys);
+
+ assertEquals(true, res);
+
+ checkEvent(data);
+ };
+
+ /**
+ *
+ */
+ protected static final Consumer<ReadRepairData> ENSURE_FIXED = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ boolean raw = data.raw;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) {
+ Integer key = entry.getKey();
+ Integer latest = entry.getValue().latest;
+
+ Integer res = raw ?
+ cache.getEntry(key).getValue() :
+ cache.get(key);
+
+ assertEquals(latest, res);
+ }
+ };
+
+ /**
+ *
+ */
+ @Test
+ public void test() throws Exception {
+ for (Ignite node : G.allGrids()) {
+ testGetVariations(node);
+ testGetNull(node);
+ testContainsVariations(node);
+ }
+ }
+
+ /**
+ *
+ */
+ private void testGetVariations(Ignite initiator) throws Exception {
+ testGet(initiator, 1, false); // just get
+ testGet(initiator, 1, true); // 1 (all keys available at primary)
+ testGet(initiator, 2, true); // less than backups
+ testGet(initiator, 3, true); // equals to backups
+ testGet(initiator, 4, true); // equals to backups + primary
+ testGet(initiator, 10, true); // more than backups
+ }
+
+ /**
+ *
+ */
+ private void testContainsVariations(Ignite initiator) throws Exception {
+ testContains(initiator, 1, false); // just contains
+ testContains(initiator, 1, true); // 1 (all keys available at primary)
+ testContains(initiator, 2, true); // less than backups
+ testContains(initiator, 3, true); // equals to backups
+ testContains(initiator, 4, true); // equals to backups + primary
+ testContains(initiator, 10, true); // more than backups
+ }
+
+ /**
+ *
+ */
+ protected abstract void testGet(Ignite initiator, Integer cnt, boolean all) throws Exception;
+
+ /**
+ *
+ */
+ protected abstract void testGetNull(Ignite initiator) throws Exception;
+
+ /**
+ *
+ */
+ protected abstract void testContains(Ignite initiator, Integer cnt, boolean all) throws Exception;
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractReadRepairTest.java
new file mode 100644
index 0000000..30414ae
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AbstractReadRepairTest.java
@@ -0,0 +1,336 @@
+/*
+ * 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.consistency;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.function.Consumer;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.CacheConsistencyViolationEvent;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.dr.GridDrType;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Before;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.events.EventType.EVT_CONSISTENCY_VIOLATION;
+
+/**
+ *
+ */
+public abstract class AbstractReadRepairTest extends GridCommonAbstractTest {
+ /** Events. */
+ private static ConcurrentLinkedDeque<CacheConsistencyViolationEvent> evtDeq = new ConcurrentLinkedDeque<>();
+
+ /** Key. */
+ protected static int iterableKey;
+
+ /** Is client flag. */
+ protected boolean client;
+
+ /** Backups count. */
+ protected Integer backupsCount() {
+ return 3;
+ }
+
+ /** Cache mode. */
+ protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** Atomicy mode. */
+ protected CacheAtomicityMode atomicyMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ Ignite ignite = startGrids(7); // Server nodes.
+
+ grid(0).getOrCreateCache(cacheConfiguration());
+
+ client = true;
+
+ startGrid(G.allGrids().size() + 1); // Client node 1.
+ startGrid(G.allGrids().size() + 1); // Client node 2.
+
+ final IgniteEvents evts = ignite.events();
+
+ evts.remoteListen(null,
+ (IgnitePredicate<Event>)e -> {
+ assert e instanceof CacheConsistencyViolationEvent;
+
+ evtDeq.add((CacheConsistencyViolationEvent)e);
+
+ return true;
+ },
+ EVT_CONSISTENCY_VIOLATION);
+
+ awaitPartitionMapExchange();
+ }
+
+ /**
+ *
+ */
+ @Before
+ public void before() {
+ evtDeq.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ log.info("Checked " + iterableKey + " keys");
+
+ stopAllGrids();
+ }
+
+ /**
+ *
+ */
+ protected CacheConfiguration<Integer, Integer> cacheConfiguration() {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(cacheMode());
+ cfg.setAtomicityMode(atomicyMode());
+ cfg.setBackups(backupsCount());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /**
+ *
+ */
+ protected static void checkEvent(ReadRepairData data) {
+ Map<Object, Object> fixed = new HashMap<>();
+
+ while (!evtDeq.isEmpty()) {
+ CacheConsistencyViolationEvent evt = evtDeq.remove();
+
+ fixed.putAll(evt.getFixedEntries()); // Optimistic and read commited transactions produce per key fixes.
+ }
+
+ int misses = 0;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) {
+ Integer key = entry.getKey();
+ Integer latest = entry.getValue().latest;
+
+ if (latest == null)
+ misses++;
+
+ assertEquals(latest, fixed.get(key));
+ }
+
+ assertEquals(data.data.size() - misses, fixed.size());
+
+ assertTrue(evtDeq.isEmpty());
+ }
+
+ /**
+ *
+ */
+ protected void prepareAndCheck(
+ Ignite initiator,
+ Integer cnt,
+ boolean raw,
+ boolean async,
+ Consumer<ReadRepairData> c)
+ throws Exception {
+ IgniteCache<Integer, Integer> cache = initiator.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+ for (int i = 0; i < ThreadLocalRandom.current().nextInt(1, 10); i++) {
+ Map<Integer, InconsistentMapping> results = new HashMap<>();
+
+ for (int j = 0; j < cnt; j++) {
+ InconsistentMapping res = setDifferentValuesForSameKey(++iterableKey);
+
+ results.put(iterableKey, res);
+ }
+
+ for (Ignite node : G.allGrids()) { // Check that cache filled properly.
+ Map<Integer, Integer> all =
+ node.<Integer, Integer>getOrCreateCache(DEFAULT_CACHE_NAME).getAll(results.keySet());
+
+ for (Map.Entry<Integer, Integer> entry : all.entrySet()) {
+ Integer key = entry.getKey();
+ Integer val = entry.getValue();
+
+ Integer exp = results.get(key).mapping.get(node); // Should read from itself (backup or primary).
+
+ if (exp == null)
+ exp = results.get(key).primary; // Should read from primary (not a partition owner).
+
+ assertEquals(exp, val);
+ }
+ }
+
+ c.accept(new ReadRepairData(cache, results, raw, async));
+ }
+ }
+
+ /**
+ *
+ */
+ private InconsistentMapping setDifferentValuesForSameKey(
+ int key) throws Exception {
+ List<Ignite> nodes = new ArrayList<>();
+ Map<Ignite, Integer> mapping = new HashMap<>();
+
+ Ignite primary = primaryNode(key, DEFAULT_CACHE_NAME);
+
+ if (ThreadLocalRandom.current().nextBoolean()) { // Reversed order.
+ nodes.addAll(backupNodes(key, DEFAULT_CACHE_NAME));
+ nodes.add(primary);
+ }
+ else {
+ nodes.add(primary);
+ nodes.addAll(backupNodes(key, DEFAULT_CACHE_NAME));
+ }
+
+ if (ThreadLocalRandom.current().nextBoolean()) // Random order.
+ Collections.shuffle(nodes);
+
+ GridCacheVersionManager mgr =
+ ((GridCacheAdapter)(grid(1)).cachex(DEFAULT_CACHE_NAME).cache()).context().shared().versions();
+
+ int val = 0;
+ int primVal = -1;
+
+ for (Ignite node : nodes) {
+ IgniteInternalCache cache = ((IgniteEx)node).cachex(DEFAULT_CACHE_NAME);
+
+ GridCacheAdapter adapter = ((GridCacheAdapter)cache.cache());
+
+ GridCacheEntryEx entry = adapter.entryEx(key);
+
+ boolean init = entry.initialValue(
+ new CacheObjectImpl(++val, null), // Incremental value.
+ mgr.next(), // Incremental version.
+ 0,
+ 0,
+ false,
+ AffinityTopologyVersion.NONE,
+ GridDrType.DR_NONE,
+ false);
+
+ assertTrue("iterableKey " + key + " already inited", init);
+
+ mapping.put(node, val);
+
+ if (node.equals(primary))
+ primVal = val;
+ }
+
+ assertEquals(nodes.size(), new HashSet<>(mapping.values()).size()); // Each node have unique value.
+
+ assertTrue(primVal != -1); // Primary value set.
+
+ return new InconsistentMapping(mapping, primVal, val);
+ }
+
+ /**
+ *
+ */
+ protected static final class ReadRepairData {
+ /** Initiator's cache. */
+ IgniteCache<Integer, Integer> cache;
+
+ /** Generated data across topology per key mapping. */
+ Map<Integer, InconsistentMapping> data;
+
+ /** Raw read flag. True means required GetEntry() instead of get(). */
+ boolean raw;
+
+ /** Async read flag. */
+ boolean async;
+
+ /**
+ *
+ */
+ public ReadRepairData(
+ IgniteCache<Integer, Integer> cache,
+ Map<Integer, InconsistentMapping> data,
+ boolean raw,
+ boolean async) {
+ this.cache = cache;
+ this.data = new HashMap<>(data);
+ this.raw = raw;
+ this.async = async;
+ }
+ }
+
+ /**
+ *
+ */
+ protected static final class InconsistentMapping {
+ /** Value per node. */
+ Map<Ignite, Integer> mapping;
+
+ /** Primary node's value. */
+ Integer primary;
+
+ /** Latest value across the topology. */
+ Integer latest;
+
+ /**
+ *
+ */
+ public InconsistentMapping(Map<Ignite, Integer> mapping, Integer primary, Integer latest) {
+ this.mapping = new HashMap<>(mapping);
+ this.primary = primary;
+ this.latest = latest;
+ }
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AtomicReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AtomicReadRepairTest.java
new file mode 100644
index 0000000..9f9fb6e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/AtomicReadRepairTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.consistency;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ * Ideally, this test should be equal to {@link ImplicitTransactionalReadRepairTest} except atomicy mode
+ * configuration.
+ *
+ * Implement repair on atomic caches to make this happen :)
+ */
+@RunWith(Parameterized.class)
+public class AtomicReadRepairTest extends ImplicitTransactionalReadRepairTest {
+ /**
+ *
+ */
+ private static final Consumer<ReadRepairData> GET_CHECK_AND_FAIL = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean raw = data.raw;
+ boolean async = data.async;
+
+ assert keys.size() == 1;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) { // Once.
+ try {
+ Integer key = entry.getKey();
+
+ Integer res =
+ raw ?
+ async ?
+ cache.withReadRepair().getEntryAsync(key).get().getValue() :
+ cache.withReadRepair().getEntry(key).getValue() :
+ async ?
+ cache.withReadRepair().getAsync(key).get() :
+ cache.withReadRepair().get(key);
+
+ fail("Should not happen.");
+ }
+ catch (CacheException e) {
+ assertTrue(e.getCause() instanceof IgniteConsistencyViolationException);
+ }
+ }
+ };
+
+ /**
+ *
+ */
+ private static final Consumer<ReadRepairData> GETALL_CHECK_AND_FAIL = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean raw = data.raw;
+ boolean async = data.async;
+
+ assert !keys.isEmpty();
+
+ try {
+ if (raw) {
+ Collection<CacheEntry<Integer, Integer>> res =
+ async ?
+ cache.withReadRepair().getEntriesAsync(keys).get() :
+ cache.withReadRepair().getEntries(keys);
+
+ for (CacheEntry<Integer, Integer> entry : res)
+ assertEquals(data.data.get(entry.getKey()).latest, entry.getValue());
+ }
+ else {
+ Map<Integer, Integer> res =
+ async ?
+ cache.withReadRepair().getAllAsync(keys).get() :
+ cache.withReadRepair().getAll(keys);
+
+ for (Map.Entry<Integer, Integer> entry : res.entrySet())
+ assertEquals(data.data.get(entry.getKey()).latest, entry.getValue());
+ }
+
+ fail("Should not happen.");
+ }
+ catch (CacheException e) {
+ assertTrue(e.getCause() instanceof IgniteConsistencyViolationException);
+ }
+ };
+
+ /**
+ *
+ */
+ private static final Consumer<ReadRepairData> CONTAINS_CHECK_AND_FAIL = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean async = data.async;
+
+ assert keys.size() == 1;
+
+ for (Map.Entry<Integer, InconsistentMapping> entry : data.data.entrySet()) { // Once.
+ try {
+ Integer key = entry.getKey();
+
+ boolean res = async ?
+ cache.withReadRepair().containsKeyAsync(key).get() :
+ cache.withReadRepair().containsKey(key);
+
+ fail("Should not happen.");
+ }
+ catch (Exception e) {
+ assertTrue(e.getCause() instanceof IgniteConsistencyViolationException);
+ }
+ }
+ };
+
+ /**
+ *
+ */
+ private static final Consumer<ReadRepairData> CONTAINS_ALL_CHECK_AND_FAIL = (data) -> {
+ IgniteCache<Integer, Integer> cache = data.cache;
+ Set<Integer> keys = data.data.keySet();
+ boolean async = data.async;
+
+ try {
+ boolean res = async ?
+ cache.withReadRepair().containsKeysAsync(keys).get() :
+ cache.withReadRepair().containsKeys(keys);
+
+ fail("Should not happen.");
+ }
+ catch (Exception e) {
+ assertTrue(e.getCause() instanceof IgniteConsistencyViolationException);
+ }
+ };
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicyMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testGet(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ if (all)
+ GETALL_CHECK_AND_FAIL.accept(data);
+ else
+ GET_CHECK_AND_FAIL.accept(data);
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testContains(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ if (all)
+ CONTAINS_ALL_CHECK_AND_FAIL.accept(data);
+ else
+ CONTAINS_CHECK_AND_FAIL.accept(data);
+ });
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ExplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ExplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..5e0e2b3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ExplicitTransactionalReadRepairTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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.consistency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionRollbackException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ *
+ */
+@RunWith(Parameterized.class)
+public class ExplicitTransactionalReadRepairTest extends AbstractFullSetReadRepairTest {
+ /** Test parameters. */
+ @Parameterized.Parameters(name = "concurrency={0}, isolation={1}, getEntry={2}, async={3}")
+ public static Collection parameters() {
+ List<Object[]> res = new ArrayList<>();
+
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (boolean raw : new boolean[] {false, true}) {
+ for (boolean async : new boolean[] {false, true})
+ res.add(new Object[] {concurrency, isolation, raw, async});
+ }
+ }
+ }
+
+ return res;
+ }
+
+ /** Concurrency. */
+ @Parameterized.Parameter
+ public TransactionConcurrency concurrency;
+
+ /** Isolation. */
+ @Parameterized.Parameter(1)
+ public TransactionIsolation isolation;
+
+ /** GetEntry or just get. */
+ @Parameterized.Parameter(2)
+ public boolean raw;
+
+ /** Async. */
+ @Parameterized.Parameter(3)
+ public boolean async;
+
+ /** {@inheritDoc} */
+ @Override protected void testGet(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ try (Transaction tx = initiator.transactions().txStart(concurrency, isolation)) {
+ // Recovery (inside tx).
+ if (all)
+ GETALL_CHECK_AND_FIX.accept(data);
+ else
+ GET_CHECK_AND_FIX.accept(data);
+
+ ENSURE_FIXED.accept(data); // Checks (inside tx).
+
+ try {
+ tx.commit();
+ }
+ catch (TransactionRollbackException e) {
+ fail("Should not happen. " + e);
+ }
+ }
+
+ ENSURE_FIXED.accept(data); // Checks (outside tx).
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testGetNull(Ignite initiator) throws Exception {
+ prepareAndCheck(
+ initiator,
+ 1,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ try (Transaction tx = initiator.transactions().txStart(concurrency, isolation)) {
+ GET_NULL.accept(data);
+
+ try {
+ tx.commit();
+ }
+ catch (TransactionRollbackException e) {
+ fail("Should not happen. " + e);
+ }
+ }
+
+ GET_NULL.accept(data); // Checks (outside tx).
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testContains(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ try (Transaction tx = initiator.transactions().txStart(concurrency, isolation)) {
+ // Recovery (inside tx).
+ if (all)
+ CONTAINS_ALL_CHECK_AND_FIX.accept(data);
+ else
+ CONTAINS_CHECK_AND_FIX.accept(data);
+
+ ENSURE_FIXED.accept(data); // Checks (inside tx).
+
+ try {
+ tx.commit();
+ }
+ catch (TransactionRollbackException e) {
+ fail("Should not happen. " + e);
+ }
+ }
+
+ ENSURE_FIXED.accept(data); // Checks (outside tx).
+ });
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ImplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ImplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..c8d9f86
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ImplicitTransactionalReadRepairTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.consistency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ *
+ */
+@RunWith(Parameterized.class)
+public class ImplicitTransactionalReadRepairTest extends AbstractFullSetReadRepairTest {
+ /** Test parameters. */
+ @Parameterized.Parameters(name = "getEntry={0}, async={1}")
+ public static Collection parameters() {
+ List<Object[]> res = new ArrayList<>();
+
+ for (boolean raw : new boolean[] {false, true}) {
+ for (boolean async : new boolean[] {false, true})
+ res.add(new Object[] {raw, async});
+ }
+
+ return res;
+ }
+
+ /** GetEntry or just get. */
+ @Parameterized.Parameter
+ public boolean raw;
+
+ /** Async. */
+ @Parameterized.Parameter(1)
+ public boolean async;
+
+ /** {@inheritDoc} */
+ @Override protected void testGet(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ if (all)
+ GETALL_CHECK_AND_FIX.accept(data);
+ else
+ GET_CHECK_AND_FIX.accept(data);
+
+ ENSURE_FIXED.accept(data);
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testGetNull(Ignite initiator) throws Exception {
+ prepareAndCheck(
+ initiator,
+ 1,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ GET_NULL.accept(data); // first attempt.
+ GET_NULL.accept(data); // second attempt (checks first attempt causes no changes/fixes/etc).
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void testContains(Ignite initiator, Integer cnt, boolean all) throws Exception {
+ prepareAndCheck(
+ initiator,
+ cnt,
+ raw,
+ async,
+ (ReadRepairData data) -> {
+ if (all)
+ CONTAINS_ALL_CHECK_AND_FIX.accept(data);
+ else
+ CONTAINS_CHECK_AND_FIX.accept(data);
+
+ ENSURE_FIXED.accept(data);
+ });
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedExplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedExplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..c5dcd28
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedExplicitTransactionalReadRepairTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.consistency;
+
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class ReplicatedExplicitTransactionalReadRepairTest extends ExplicitTransactionalReadRepairTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.REPLICATED;
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedImplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedImplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..a244658
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/ReplicatedImplicitTransactionalReadRepairTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.consistency;
+
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class ReplicatedImplicitTransactionalReadRepairTest extends ImplicitTransactionalReadRepairTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.REPLICATED;
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupExplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupExplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..13ed4bd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupExplicitTransactionalReadRepairTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.consistency;
+
+/**
+ *
+ */
+public class SingleBackupExplicitTransactionalReadRepairTest extends ExplicitTransactionalReadRepairTest {
+ /** {@inheritDoc} */
+ @Override protected Integer backupsCount() {
+ return 1; // Single backup possible optimisations check.
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupImplicitTransactionalReadRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupImplicitTransactionalReadRepairTest.java
new file mode 100644
index 0000000..9d77fd4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistency/SingleBackupImplicitTransactionalReadRepairTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.consistency;
+
+/**
+ *
+ */
+public class SingleBackupImplicitTransactionalReadRepairTest extends ImplicitTransactionalReadRepairTest {
+ /** {@inheritDoc} */
+ @Override protected Integer backupsCount() {
+ return 1; // Single backup possible optimisations check.
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
index d515c49..7622469 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
@@ -238,7 +238,7 @@ public class GridCacheDhtEvictionNearReadersSelfTest extends GridCommonAbstractT
// waitForLocalEvent(grid(primary).events(), nodeEvent(primary.id()), EVT_CACHE_ENTRY_EVICTED);
// Get value on other node, it should be loaded to near cache.
- assertEquals(val, nearOther.get(key, true, false));
+ assertEquals(val, nearOther.repairableGet(key, true, false));
entryPrimary = (GridDhtCacheEntry)dhtPrimary.peekEx(key);
entryBackup = (GridDhtCacheEntry)dhtBackup.peekEx(key);
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index f9432ed..8192ead 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -140,6 +140,11 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public IgniteCache<K, V> withReadRepair() {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
throws CacheException {
throw new UnsupportedOperationException("Method should be supported.");
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
index f7f6e22..a8b075e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
@@ -18,6 +18,13 @@
package org.apache.ignite.testsuites;
import org.apache.ignite.internal.processors.cache.AtomicCacheAffinityConfigurationTest;
+import org.apache.ignite.internal.processors.cache.consistency.AtomicReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.ExplicitTransactionalReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.ImplicitTransactionalReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.ReplicatedExplicitTransactionalReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.ReplicatedImplicitTransactionalReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.SingleBackupExplicitTransactionalReadRepairTest;
+import org.apache.ignite.internal.processors.cache.consistency.SingleBackupImplicitTransactionalReadRepairTest;
import org.apache.ignite.internal.processors.cache.datastructures.GridCacheQueueCleanupSelfTest;
import org.apache.ignite.internal.processors.cache.datastructures.GridCacheQueueClientDisconnectTest;
import org.apache.ignite.internal.processors.cache.datastructures.GridCacheQueueMultiNodeConsistencySelfTest;
@@ -184,7 +191,17 @@ import org.junit.runners.Suite;
AtomicCacheAffinityConfigurationTest.class,
- IgniteCacheDataStructuresBinarySelfTestSuite.class
+ IgniteCacheDataStructuresBinarySelfTestSuite.class,
+
+ ImplicitTransactionalReadRepairTest.class,
+ SingleBackupImplicitTransactionalReadRepairTest.class,
+ ReplicatedImplicitTransactionalReadRepairTest.class,
+
+ AtomicReadRepairTest.class,
+
+ ExplicitTransactionalReadRepairTest.class,
+ SingleBackupExplicitTransactionalReadRepairTest.class,
+ ReplicatedExplicitTransactionalReadRepairTest.class,
})
public class IgniteCacheDataStructuresSelfTestSuite {
}
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
index 86c99db..9d1fe2b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java
@@ -534,7 +534,7 @@ public class DmlUtils {
if (opCtx == null)
// Mimics behavior of GridCacheAdapter#keepBinary and GridCacheProxyImpl#keepBinary
- newOpCtx = new CacheOperationContext(false, null, true, null, false, null, false, true);
+ newOpCtx = new CacheOperationContext(false, null, true, null, false, null, false, false, true);
else if (!opCtx.isKeepBinary())
newOpCtx = opCtx.keepBinary();
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
index 3094e86..10b0da9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
@@ -107,6 +107,8 @@ namespace Apache.Ignite.AspNet.Tests
}
public bool IsKeepBinary { get; private set; }
+
+ public bool IsReadRepair { get; private set; }
public bool IsAllowAtomicOpsInTx { get; private set; }
@@ -130,6 +132,11 @@ namespace Apache.Ignite.AspNet.Tests
throw new NotImplementedException();
}
+ public ICache<int, int> WithReadRepair()
+ {
+ throw new NotImplementedException();
+ }
+
public void LoadCache(ICacheEntryFilter<int, int> p, params object[] args)
{
throw new NotImplementedException();
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 71c695e1..3c03f74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -78,6 +78,12 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public bool IsReadRepair
+ {
+ get { return _cache.IsReadRepair; }
+ }
+
+ /** <inheritDoc /> */
public bool IsAllowAtomicOpsInTx {
get { return _cache.IsAllowAtomicOpsInTx; }
}
@@ -107,6 +113,12 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public ICache<TK, TV> WithReadRepair()
+ {
+ return _cache.WithReadRepair().WrapAsync();
+ }
+
+ /** <inheritDoc /> */
public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
{
_cache.LoadCacheAsync(p, args).WaitResult();
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index deb1cc5..3b63eca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -85,6 +85,11 @@ namespace Apache.Ignite.Core.Cache
bool IsKeepBinary { get; }
/// <summary>
+ /// Gets a value indicating whether to consistency should be checked and fixed if necessary.
+ /// </summary>
+ bool IsReadRepair { get; }
+
+ /// <summary>
/// Gets a value indicating whether to allow use atomic operations in transactions.
/// </summary>
bool IsAllowAtomicOpsInTx { get; }
@@ -124,6 +129,14 @@ namespace Apache.Ignite.Core.Cache
ICache<TK, TV> WithAllowAtomicOpsInTx();
/// <summary>
+ /// Gets cache with Consistency mode enabled.
+ /// Each explicit get operation will check data is consistent over the topology, each backup value
+ /// will be compared with primary and fixed in case consistency violation found.
+ /// </summary>
+ /// <returns>Cache instance with consistency mode enabled.</returns>
+ ICache<TK, TV> WithReadRepair();
+
+ /// <summary>
/// Executes <see cref="LocalLoadCache"/> on all cache nodes.
/// </summary>
/// <param name="p">
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 34fdcce..97b31be 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -63,6 +63,9 @@ namespace Apache.Ignite.Core.Impl.Cache
/** Flag: partition recover.*/
private readonly bool _flagPartitionRecover;
+ /** Flag: consistency.*/
+ private readonly bool _flagReadRepair;
+
/** Transaction manager. */
private readonly CacheTransactionManager _txManager;
@@ -77,16 +80,18 @@ namespace Apache.Ignite.Core.Impl.Cache
/// <param name="flagKeepBinary">Keep binary flag.</param>
/// <param name="flagNoRetries">No-retries mode flag.</param>
/// <param name="flagPartitionRecover">Partition recover mode flag.</param>
+ /// <param name="flagReadRepair">Read Repair mode flag.</param>
/// <param name="flagAllowAtomicOpsInTx">Allow atomic operations in transactions flag.</param>
public CacheImpl(IPlatformTargetInternal target,
bool flagSkipStore, bool flagKeepBinary, bool flagNoRetries, bool flagPartitionRecover,
- bool flagAllowAtomicOpsInTx) : base(target)
+ bool flagReadRepair, bool flagAllowAtomicOpsInTx) : base(target)
{
_ignite = target.Marshaller.Ignite;
_flagSkipStore = flagSkipStore;
_flagKeepBinary = flagKeepBinary;
_flagNoRetries = flagNoRetries;
_flagPartitionRecover = flagPartitionRecover;
+ _flagReadRepair = flagReadRepair;
_flagAllowAtomicOpsInTx = flagAllowAtomicOpsInTx;
_txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
@@ -178,7 +183,7 @@ namespace Apache.Ignite.Core.Impl.Cache
return this;
return new CacheImpl<TK, TV>(DoOutOpObject((int) CacheOp.WithSkipStore),
- true, _flagKeepBinary, true, _flagPartitionRecover, _flagAllowAtomicOpsInTx);
+ true, _flagKeepBinary, true, _flagPartitionRecover, _flagReadRepair, _flagAllowAtomicOpsInTx);
}
/// <summary>
@@ -202,7 +207,7 @@ namespace Apache.Ignite.Core.Impl.Cache
}
return new CacheImpl<TK1, TV1>(DoOutOpObject((int) CacheOp.WithKeepBinary),
- _flagSkipStore, true, _flagNoRetries, _flagPartitionRecover, _flagAllowAtomicOpsInTx);
+ _flagSkipStore, true, _flagNoRetries, _flagPartitionRecover, _flagReadRepair, _flagAllowAtomicOpsInTx);
}
/** <inheritDoc /> */
@@ -212,7 +217,17 @@ namespace Apache.Ignite.Core.Impl.Cache
return this;
return new CacheImpl<TK, TV>(DoOutOpObject((int)CacheOp.WithSkipStore),
- true, _flagKeepBinary, _flagSkipStore, _flagPartitionRecover, true);
+ true, _flagKeepBinary, _flagSkipStore, _flagPartitionRecover, _flagReadRepair, true);
+ }
+
+ /** <inheritDoc /> */
+ public ICache<TK, TV> WithReadRepair()
+ {
+ if (_flagReadRepair)
+ return this;
+
+ return new CacheImpl<TK, TV>(DoOutOpObject((int)CacheOp.WithReadRepair),
+ true, _flagKeepBinary, _flagSkipStore, _flagPartitionRecover, true, _flagAllowAtomicOpsInTx);
}
/** <inheritDoc /> */
@@ -223,7 +238,7 @@ namespace Apache.Ignite.Core.Impl.Cache
var cache0 = DoOutOpObject((int)CacheOp.WithExpiryPolicy, w => ExpiryPolicySerializer.WritePolicy(w, plc));
return new CacheImpl<TK, TV>(cache0, _flagSkipStore, _flagKeepBinary,
- _flagNoRetries, _flagPartitionRecover, _flagAllowAtomicOpsInTx);
+ _flagNoRetries, _flagPartitionRecover, _flagReadRepair, _flagAllowAtomicOpsInTx);
}
/** <inheritDoc /> */
@@ -233,6 +248,11 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public bool IsReadRepair {
+ get { return _flagReadRepair; }
+ }
+
+ /** <inheritDoc /> */
public bool IsAllowAtomicOpsInTx {
get { return _flagAllowAtomicOpsInTx; }
}
@@ -1139,7 +1159,7 @@ namespace Apache.Ignite.Core.Impl.Cache
return this;
return new CacheImpl<TK, TV>(DoOutOpObject((int) CacheOp.WithNoRetries),
- _flagSkipStore, _flagKeepBinary, true, _flagPartitionRecover, _flagAllowAtomicOpsInTx);
+ _flagSkipStore, _flagKeepBinary, true, _flagPartitionRecover, _flagReadRepair, _flagAllowAtomicOpsInTx);
}
/** <inheritDoc /> */
@@ -1149,7 +1169,7 @@ namespace Apache.Ignite.Core.Impl.Cache
return this;
return new CacheImpl<TK, TV>(DoOutOpObject((int) CacheOp.WithPartitionRecover),
- _flagSkipStore, _flagKeepBinary, _flagNoRetries, true, _flagAllowAtomicOpsInTx);
+ _flagSkipStore, _flagKeepBinary, _flagNoRetries, true, _flagReadRepair, _flagAllowAtomicOpsInTx);
}
/** <inheritDoc /> */
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 836f49d..1195bf8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -112,6 +112,7 @@ namespace Apache.Ignite.Core.Impl.Cache
LocalPreloadPartition = 89,
SizeLong = 90,
SizeLongAsync = 91,
- SizeLongLoc = 92
+ SizeLongLoc = 92,
+ WithReadRepair = 93
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 14ee486..6c209e0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -528,7 +528,7 @@ namespace Apache.Ignite.Core.Impl
/// </returns>
public static ICache<TK, TV> GetCache<TK, TV>(IPlatformTargetInternal nativeCache, bool keepBinary = false)
{
- return new CacheImpl<TK, TV>(nativeCache, false, keepBinary, false, false, false);
+ return new CacheImpl<TK, TV>(nativeCache, false, keepBinary, false, false, false, false);
}
/** <inheritdoc /> */