Author: mreutegg
Date: Wed Oct 8 12:38:54 2014
New Revision: 1630084
URL: http://svn.apache.org/r1630084
Log:
OAK-2167: Last revision recover incomplete
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/DocumentNodeStoreBranch.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeeker.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.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=1630084&r1=1630083&r2=1630084&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 Oct 8 12:38:54 2014
@@ -154,6 +154,12 @@ public final class DocumentNodeStore
protected int asyncDelay = 1000;
/**
+ * The maximum back off time in milliseconds when merges are retried. The
+ * default value is twice the {@link #asyncDelay}.
+ */
+ protected int maxBackOffMillis = asyncDelay * 2;
+
+ /**
* Whether this instance is disposed.
*/
private final AtomicBoolean isDisposed = new AtomicBoolean();
@@ -576,6 +582,14 @@ public final class DocumentNodeStore
return asyncDelay;
}
+ public void setMaxBackOffMillis(int time) {
+ maxBackOffMillis = time;
+ }
+
+ public int getMaxBackOffMillis() {
+ return maxBackOffMillis;
+ }
+
@CheckForNull
public ClusterNodeInfo getClusterInfo() {
return clusterNodeInfo;
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java?rev=1630084&r1=1630083&r2=1630084&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
Wed Oct 8 12:38:54 2014
@@ -47,8 +47,8 @@ class DocumentNodeStoreBranch
DocumentNodeState base,
ReadWriteLock mergeLock) {
super(store, new ChangeDispatcher(store.getRoot()),
mergeLock.readLock(),
- base, null, getMaxBackoffMillis(store),
- getMaxBackoffMillis(store) * 3);
+ base, null, store.getMaxBackOffMillis(),
+ store.getMaxBackOffMillis() * 3);
this.mergeLock = mergeLock;
}
@@ -168,11 +168,6 @@ class DocumentNodeStoreBranch
//------------------------------< internal
>--------------------------------
- private static long getMaxBackoffMillis(DocumentNodeStore store) {
- // maximum back off is twice the async delay, but at least 2 seconds.
- return Math.max(store.getAsyncDelay(), 1000) * 2;
- }
-
/**
* Persist some changes on top of the given base state.
*
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java?rev=1630084&r1=1630083&r2=1630084&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
Wed Oct 8 12:38:54 2014
@@ -97,14 +97,10 @@ public class LastRevRecoveryAgent {
startTime = leaseEnd - leaseTime - asyncDelay;
}
- // Endtime is the leaseEnd + the asyncDelay
- long endTime = leaseEnd + asyncDelay;
+ log.info("Recovering candidates modified after: [{}] for
clusterId [{}]",
+ Utils.timestampToString(startTime), clusterId);
- log.info("Recovering candidates modified in time range :
[{},{}] for clusterId [{}]",
- Utils.timestampToString(startTime),
- Utils.timestampToString(endTime), clusterId);
-
- return recoverCandidates(clusterId, startTime, endTime);
+ return recoverCandidates(clusterId, startTime);
}
}
@@ -230,15 +226,14 @@ public class LastRevRecoveryAgent {
}
/**
- * Retrieves possible candidates which have been modifed in the time range
and recovers the
- * missing updates.
+ * Retrieves possible candidates which have been modified after the given
+ * {@code startTime} and recovers the missing updates.
*
* @param clusterId the cluster id
* @param startTime the start time
- * @param endTime the end time
* @return the int the number of restored nodes
*/
- private int recoverCandidates(final int clusterId, final long startTime,
final long endTime) {
+ private int recoverCandidates(final int clusterId, final long startTime) {
boolean lockAcquired =
missingLastRevUtil.acquireRecoveryLock(clusterId);
//TODO What if recovery is being performed for current clusterNode by
some other node
@@ -249,7 +244,7 @@ public class LastRevRecoveryAgent {
return 0;
}
- Iterable<NodeDocument> suspects =
missingLastRevUtil.getCandidates(startTime, endTime);
+ Iterable<NodeDocument> suspects =
missingLastRevUtil.getCandidates(startTime);
log.debug("Performing Last Revision recovery for cluster {}",
clusterId);
try {
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=1630084&r1=1630083&r2=1630084&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 Oct 8 12:38:54 2014
@@ -61,13 +61,13 @@ public class MissingLastRevSeeker {
}
/**
- * Get the candidates with modified time between the time range specified.
+ * Get the candidates with modified time after the specified
+ * {@code startTime}.
*
- * @param startTime the start of the time range
- * @param endTime the end of the time range
+ * @param startTime the start time.
* @return the candidates
*/
- public Iterable<NodeDocument> getCandidates(final long startTime, final
long endTime) {
+ public Iterable<NodeDocument> getCandidates(final long startTime) {
// Fetch all documents where lastmod >= startTime
List<NodeDocument> nodes = store.query(Collection.NODES,
NodeDocument.MIN_ID_VALUE,
NodeDocument.MAX_ID_VALUE, NodeDocument.MODIFIED_IN_SECS,
NodeDocument.getModifiedInSecs(startTime), Integer.MAX_VALUE);
@@ -76,8 +76,7 @@ public class MissingLastRevSeeker {
public boolean apply(NodeDocument input) {
Long modified = (Long)
input.get(NodeDocument.MODIFIED_IN_SECS);
return (modified != null
- && (modified >=
NodeDocument.getModifiedInSecs(startTime))
- && (modified <=
NodeDocument.getModifiedInSecs(endTime)));
+ && (modified >=
NodeDocument.getModifiedInSecs(startTime)));
}
});
}
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeeker.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeeker.java?rev=1630084&r1=1630083&r2=1630084&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeeker.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeeker.java
Wed Oct 8 12:38:54 2014
@@ -53,12 +53,9 @@ public class MongoMissingLastRevSeeker e
}
@Override
- public CloseableIterable<NodeDocument> getCandidates(final long startTime,
- final long endTime) {
+ public CloseableIterable<NodeDocument> getCandidates(final long startTime)
{
DBObject query =
- start(NodeDocument.MODIFIED_IN_SECS).lessThanEquals(
- NodeDocument.getModifiedInSecs(endTime))
- .put(NodeDocument.MODIFIED_IN_SECS).greaterThanEquals(
+ start(NodeDocument.MODIFIED_IN_SECS).greaterThanEquals(
NodeDocument.getModifiedInSecs(startTime))
.get();
DBObject sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS,
-1);
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java?rev=1630084&r1=1630083&r2=1630084&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
Wed Oct 8 12:38:54 2014
@@ -32,7 +32,6 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.stats.Clock;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -183,9 +182,12 @@ public class LastRevRecoveryAgentTest {
assertFalse(ds1.getLastRevRecoveryAgent().isRecoveryNeeded());
}
- @Ignore("OAK-2167")
@Test
public void recoveryOfModifiedDocument() throws Exception {
+ // do not retry merges
+ ds1.setMaxBackOffMillis(0);
+ ds2.setMaxBackOffMillis(0);
+
NodeBuilder b1 = ds1.getRoot().builder();
b1.child("x").child("y").setProperty("p", "v1");
merge(ds1, b1);