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 2016/09/13 06:51:05 UTC

svn commit: r1760486 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java

Author: mreutegg
Date: Tue Sep 13 06:51:05 2016
New Revision: 1760486

URL: http://svn.apache.org/viewvc?rev=1760486&view=rev
Log:
OAK-4779: ClusterNodeInfo may renew lease while recovery is running

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java?rev=1760486&r1=1760485&r2=1760486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java Tue Sep 13 06:51:05 2016
@@ -819,6 +819,8 @@ public class ClusterNodeInfo {
             update.equals(LEASE_END_KEY, null, previousLeaseEndTime);
             // plus it must still be active ..
             update.equals(STATE, null, ClusterNodeState.ACTIVE.name());
+            // plus it must not have a recovery lock on it
+            update.notEquals(REV_RECOVERY_LOCK, RecoverLockState.ACQUIRED.name());
             // @TODO: to make it 100% failure proof we could introduce
             // yet another field to clusterNodes: a runtimeId that we
             // create (UUID) at startup each time - and against that
@@ -846,10 +848,24 @@ public class ClusterNodeInfo {
                 }
                 leaseCheckFailed = true; // make sure only one thread 'wins', ie goes any further
             }
-            final String errorMsg = LEASE_CHECK_FAILED_MSG+
-                    " (Could not update lease anymore, someone else in the cluster "
-                    + "must have noticed this instance' slowness already. "
-                    + "Going to invoke leaseFailureHandler!)";
+
+            String errorMsg = LEASE_CHECK_FAILED_MSG + " (Could not update lease anymore, someone else in the cluster "
+                    + "must have noticed this instance' slowness already. " + "Going to invoke leaseFailureHandler!)";
+
+            // try to add more diagnostics
+            try {
+                ClusterNodeInfoDocument current = store.find(Collection.CLUSTER_NODES, "" + id);
+                if (current != null) {
+                    Object leaseEnd = current.get(LEASE_END_KEY);
+                    Object recoveryLock = current.get(REV_RECOVERY_LOCK);
+                    Object recoveryBy = current.get(REV_RECOVERY_BY);
+                    errorMsg += " (leaseEnd: " + leaseEnd + " (expected: " + leaseEndTime + "), recoveryLock: " + recoveryLock
+                            + ", recoveryBy: " + recoveryBy + ")";
+                }
+            } catch (DocumentStoreException ex) {
+                LOG.error("trying to read ClusterNodeInfo for cluster id " + id, ex);
+            }
+
             LOG.error(errorMsg);
 
             handleLeaseFailure(errorMsg);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java?rev=1760486&r1=1760485&r2=1760486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfoTest.java Tue Sep 13 06:51:05 2016
@@ -125,7 +125,6 @@ public class ClusterNodeInfoTest {
     }
 
     // OAK-4779
-    @Ignore
     @Test
     public void renewLeaseWhileRecoveryRunning() throws Exception {
         ClusterNodeInfo info = newClusterNodeInfo(1);