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 mr...@apache.org on 2017/05/17 06:35:13 UTC
svn commit: r1795400 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/
test/java/org/apache/jackrabbit/oak/plugins/document/
Author: mreutegg
Date: Wed May 17 06:35:12 2017
New Revision: 1795400
URL: http://svn.apache.org/viewvc?rev=1795400&view=rev
Log:
OAK-3712: Clean up uncommitted changes
Sweeper uses incorrect lower bound for _modified
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1795400&r1=1795399&r2=1795400&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Wed May 17 06:35:12 2017
@@ -34,7 +34,6 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.FAST_DIFF;
import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.MANY_CHILDREN_THRESHOLD;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS_RESOLUTION;
-import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.getModifiedInSecs;
import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key;
import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation;
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.alignWithExternalRevisions;
@@ -2387,8 +2386,7 @@ public final class DocumentNodeStore
NodeDocumentSweeper sweeper = new NodeDocumentSweeper(this, false);
LOG.debug("Starting document sweep. Head: {}, starting at {}",
sweeper.getHeadRevision(), startRev);
- long lastSweepTick = getModifiedInSecs(startRev.getTimestamp());
- Iterable<NodeDocument> docs = lastRevSeeker.getCandidates(lastSweepTick);
+ Iterable<NodeDocument> docs = lastRevSeeker.getCandidates(startRev.getTimestamp());
try {
final AtomicInteger numUpdates = new AtomicInteger();
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java?rev=1795400&r1=1795399&r2=1795400&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java Wed May 17 06:35:12 2017
@@ -92,9 +92,9 @@ public class MissingLastRevSeeker {
/**
* Get the candidates with modified time greater than or equal the specified
- * {@code startTime}.
+ * {@code startTime} in milliseconds since the start of the epoch.
*
- * @param startTime the start time.
+ * @param startTime the start time in milliseconds.
* @return the candidates
*/
@Nonnull
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java?rev=1795400&r1=1795399&r2=1795400&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java Wed May 17 06:35:12 2017
@@ -17,9 +17,15 @@
package org.apache.jackrabbit.oak.plugins.document;
import java.util.List;
+import java.util.Map;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
@@ -230,6 +236,52 @@ public class DocumentNodeStoreSweepTest
assertNull(rootDoc.getSweepRevisions().getRevision(clusterId));
}
+ @Test
+ public void lowerSweepLimit() throws Exception {
+ ns.dispose();
+ // restart with a document store that tracks queries
+ final Map<String, Long> queries = Maps.newHashMap();
+ store = new FailingDocumentStore(new MemoryDocumentStore() {
+ @Nonnull
+ @Override
+ public <T extends Document> List<T> query(Collection<T> collection,
+ String fromKey,
+ String toKey,
+ String indexedProperty,
+ long startValue,
+ int limit) {
+ queries.put(indexedProperty, startValue);
+ return super.query(collection, fromKey, toKey,
+ indexedProperty, startValue, limit);
+ }
+ });
+ ns = createDocumentNodeStore(0);
+
+ createUncommittedChanges();
+ // get the revision of the uncommitted changes
+ Revision r = null;
+ for (NodeDocument d : Utils.getAllDocuments(store)) {
+ if (d.getPath().startsWith("/node-")) {
+ r = Iterables.getFirst(d.getAllChanges(), null);
+ break;
+ }
+ }
+ assertNotNull(r);
+ // after a new head and a background sweep, the
+ // uncommitted changes must be cleaned up
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child("foo");
+ merge(ns, builder);
+ queries.clear();
+ ns.runBackgroundOperations();
+ assertCleanStore();
+ // sweeper must have looked at most recently modified documents
+ Long modified = queries.get(NodeDocument.MODIFIED_IN_SECS);
+ assertNotNull(modified);
+ long startValue = NodeDocument.getModifiedInSecs(r.getTimestamp());
+ assertEquals(startValue, modified.longValue());
+ }
+
private void assertNodeExists(String path) {
NodeState n = ns.getRoot();
for (String name : PathUtils.elements(path)) {