You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2023/01/04 10:18:29 UTC
[jackrabbit-oak] 02/03: OAK-9908: Recovery may revert committed changes
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch 1.22
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit a71e0a6bbb640819e52edded3f31f50cfd08ffb1
Author: Marcel Reutegger <ma...@gmail.com>
AuthorDate: Mon Aug 22 15:58:07 2022 +0200
OAK-9908: Recovery may revert committed changes
Ensure suspect documents are either up-to-date in the cache or invalidated
Enable test
---
.../jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java | 8 ++++++++
.../jackrabbit/oak/plugins/document/NodeDocumentSweeperIT.java | 2 --
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
index e1f920f5e8..ada28007a9 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
@@ -19,6 +19,7 @@
package org.apache.jackrabbit.oak.plugins.document;
import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.filterKeys;
import static java.util.Collections.singletonList;
@@ -44,6 +45,7 @@ import com.google.common.collect.Sets;
import org.apache.jackrabbit.oak.commons.TimeDurationFormatter;
import org.apache.jackrabbit.oak.plugins.document.bundlor.DocumentBundlor;
+import org.apache.jackrabbit.oak.plugins.document.cache.CacheInvalidationStats;
import org.apache.jackrabbit.oak.plugins.document.util.MapFactory;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.stats.Clock;
@@ -260,6 +262,12 @@ public class LastRevRecoveryAgent {
revisionContext.getClock(), clusterId,
revisionContext::getCommitValue);
final NodeDocumentSweeper sweeper = new NodeDocumentSweeper(context, true);
+ // make sure recovery does not run on stale cache
+ // invalidate all suspects (OAK-9908)
+ log.info("Starting cache invalidation before sweep...");
+ CacheInvalidationStats stats = store.invalidateCache(
+ transform(suspects, Document::getId));
+ log.info("Invalidation stats: {}", stats);
sweeper.sweep(suspects, new NodeDocumentSweepListener() {
@Override
public void sweepUpdate(Map<Path, UpdateOp> updates)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperIT.java
index 8048f19ea1..1b6ba62b09 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperIT.java
@@ -29,7 +29,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import static org.apache.jackrabbit.oak.plugins.document.TestUtils.disposeQuietly;
@@ -92,7 +91,6 @@ public class NodeDocumentSweeperIT extends AbstractTwoNodeTest {
agent2 = new LastRevRecoveryAgent(ds2.getDocumentStore(), ds2, testSeeker, v -> {});
}
- @Ignore("OAK-9908")
@Test
public void recoveryWithSweep() throws Exception {
// create some test data