Author: mreutegg
Date: Tue May 9 09:33:58 2017
New Revision: 1794514
URL: http://svn.apache.org/viewvc?rev=1794514&view=rev
Log:
OAK-3711: Clean up _revision entries on commit root documents
Update sweepRevisions in background read
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java
(with props)
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/ExternalChange.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.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=1794514&r1=1794513&r2=1794514&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
Tue May 9 09:33:58 2017
@@ -2150,6 +2150,7 @@ public final class DocumentNodeStore
@Override
void updateHead(@Nonnull Set<Revision> externalChanges,
+ @Nonnull RevisionVector sweepRevs,
@Nullable Iterable<String> changedPaths) {
long time = clock.getTime();
// make sure no local commit is in progress
@@ -2163,6 +2164,9 @@ public final class DocumentNodeStore
newHead = newHead.update(r);
}
setRoot(newHead);
+ // update sweep revisions
+ sweepRevisions = sweepRevisions.pmax(sweepRevs);
+
commitQueue.headRevisionChanged();
time = clock.getTime();
if (changedPaths != null) {
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java?rev=1794514&r1=1794513&r2=1794514&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
Tue May 9 09:33:58 2017
@@ -79,10 +79,12 @@ abstract class ExternalChange {
*
* @param externalChanges the head revision of other cluster nodes that
* changed and should now be considered visible.
+ * @param sweepRevisions the current sweep revisions.
* @param changedPaths paths of nodes that are affected by those external
* changes.
*/
abstract void updateHead(@Nonnull Set<Revision> externalChanges,
+ @Nonnull RevisionVector sweepRevisions,
@Nullable Iterable<String> changedPaths);
/**
@@ -174,7 +176,7 @@ abstract class ExternalChange {
// update head
if (!externalChanges.isEmpty()) {
- updateHead(externalChanges, externalSort);
+ updateHead(externalChanges, doc.getSweepRevisions(),
externalSort);
}
} finally {
closeQuietly(externalSort);
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java?rev=1794514&r1=1794513&r2=1794514&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
Tue May 9 09:33:58 2017
@@ -173,15 +173,17 @@ public class MongoVersionGCSupport exten
private DBObject createQuery(Set<SplitDocType> gcTypes,
RevisionVector sweepRevs,
long oldestRevTimeStamp) {
+ List<Integer> gcTypeCodes = Lists.newArrayList();
QueryBuilder orClause = start();
for(SplitDocType type : gcTypes) {
+ gcTypeCodes.add(type.typeCode());
for (DBObject query : queriesForType(type, sweepRevs)) {
orClause.or(query);
}
}
return start()
.and(
- start(SD_TYPE).exists(true).get(),
+ start(SD_TYPE).in(gcTypeCodes).get(),
orClause.get(),
start(NodeDocument.SD_MAX_REV_TIME_IN_SECS)
.lessThan(NodeDocument.getModifiedInSecs(oldestRevTimeStamp))
@@ -194,8 +196,8 @@ public class MongoVersionGCSupport exten
if (type != DEFAULT_NO_BRANCH) {
return singletonList(start(SD_TYPE).is(type.typeCode()).get());
}
- // default split type is special because we can only remove those
- // older than sweep rev
+ // default_no_branch split type is special because we can
+ // only remove those older than sweep rev
List<DBObject> queries = Lists.newArrayList();
for (Revision r : sweepRevs) {
String idSuffix = Utils.getPreviousIdFor("/", r, 0);
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java?rev=1794514&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java
(added)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java
Tue May 9 09:33:58 2017
@@ -0,0 +1,66 @@
+/*
+ * 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.jackrabbit.oak.plugins.document;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+
+public class SweepRevisionOnReadOnlyStoreTest {
+
+ @Rule
+ public DocumentMKBuilderProvider builderProvider = new
DocumentMKBuilderProvider();
+
+ private DocumentNodeStore ns1;
+ private DocumentNodeStore ns2;
+
+ @Before
+ public void setup() {
+ DocumentStore store = new MemoryDocumentStore();
+ ns1 = builderProvider.newBuilder().setDocumentStore(store)
+ .setAsyncDelay(0).getNodeStore();
+ ns2 = builderProvider.newBuilder().setDocumentStore(store)
+ .setAsyncDelay(0).setReadOnlyMode().getNodeStore();
+ }
+
+ @Test
+ public void backgroundOperationUpdatesSweepRevision() throws Exception {
+ addNode(ns1, "foo");
+ ns1.runBackgroundOperations();
+ ns2.runBackgroundOperations();
+ RevisionVector sweepRev = ns2.getSweepRevisions();
+
+ addNode(ns1, "bar");
+ ns1.runBackgroundOperations();
+ ns2.runBackgroundOperations();
+
+ assertFalse(sweepRev.equals(ns2.getSweepRevisions()));
+ }
+
+ private static void addNode(NodeStore ns, String name)
+ throws CommitFailedException {
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child(name);
+ TestUtils.merge(ns, builder);
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/SweepRevisionOnReadOnlyStoreTest.java
------------------------------------------------------------------------------
svn:eol-style = native