nizhikov commented on code in PR #9907:
URL: https://github.com/apache/ignite/pull/9907#discussion_r880224843
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java:
##########
@@ -5134,6 +5139,105 @@ private IgniteInternalFuture<Void> repairAsync(
});
}
+ /**
+ * Checks the given {@code key} and repairs entry across the topology if
needed.
+ *
+ * @param key Key.
+ * @param ex Ignite atomic consistency violation exception
+ * @param opCtx Operation context.
+ * @return Recovery future.
+ */
+ private IgniteInternalFuture<Void> repairAtomicAsync(
+ final KeyCacheObject key,
+ final IgniteAtomicConsistencyViolationException ex,
+ final CacheOperationContext opCtx) {
+ assert ctx.atomic();
+
+ EntryGetResult correctedRes = ex.correctedMap().get(key);
+ EntryGetResult primRes = ex.primaryMap().get(key);
+
+ CacheObject correctedObj = correctedRes != null ? correctedRes.value()
: null;
+ CacheObject primValObj = primRes != null ? primRes.value() : null;
+
+ V correctedVal = correctedObj != null ?
(V)ctx.unwrapBinaryIfNeeded(correctedObj, true, false, null) : null;
+ V primVal = primValObj != null ?
(V)ctx.unwrapBinaryIfNeeded(primValObj, true, false, null) : null;
+
+ GridCacheVersion primVer = primRes != null ? primRes.version() : null;
+
+ return ctx.kernalContext().closure().callLocalSafe(new
GridPlainCallable<Boolean>() {
+ @Override public Boolean call() throws IgniteCheckedException {
+ CacheOperationContext prevOpCtx =
ctx.operationContextPerCall();
+
+ ctx.operationContextPerCall(opCtx.keepBinary());
+
+ try {
+ return invoke((K)key, new
AtomicReadRepairEntryProcessor<>(correctedVal, primVal, primVer)).get();
+ }
+ finally {
+ ctx.operationContextPerCall(prevOpCtx);
+ }
+ }
+ }).chain(fut -> {
+ if (fut.result())
+ ex.onRepaired(key); // Event recording after fixed.
+
+ return null;
+ });
+ }
+
+ /**
+ *
+ */
+ protected static final class AtomicReadRepairEntryProcessor<K, V>
implements CacheEntryProcessor<K, V, Boolean> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Corrected value. */
+ private final V correctedVal;
+
+ /** Primary value.*/
+ private final V primVal;
+
+ /** Primary version. */
+ private final GridCacheVersion primVer;
+
+ /**
+ * @param correctedVal Corrected value.
+ * @param primVal Primary value.
+ * @param primVer Primary version.
+ */
+ public AtomicReadRepairEntryProcessor(V correctedVal, V primVal,
GridCacheVersion primVer) {
+ this.correctedVal = correctedVal;
+ this.primVal = primVal;
+ this.primVer = primVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean process(MutableEntry<K, V> entry, Object...
arguments) throws EntryProcessorException {
+ V entryVal = entry.getValue();
+
+ try {
+ if ((primVal == null && entryVal == null) || // Still null at
primary.
Review Comment:
```
(primVal == null && entryVal == null) || // Still null at primary.
// No updates since consistency violation has been found.
((primVal != null && primVal.equals(entryVal)
```
Can be replaced with `Objects.equals`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]