Recovery runs mistakenly when system clock jumps ahead
Restructure code a bit as suggested by Stefan Egli
@@ -146,14 +146,12 @@ public class LastRevRecoveryAgent {
// Check our own lease before running recovery for another
// clusterId (OAK-9656)
long now = revisionContext.getClock().getTime();
- ClusterNodeInfoDocument me = null;
if (clusterId != revisionContext.getClusterId()) {
// Get leaseEnd from our own cluster node info, unless
// we are doing recovery on startup for the clusterId
// we want to acquire. Then it's fine to go ahead with
// an expired lease.
- me = missingLastRevUtil.getClusterNodeInfo(revisionContext.getClusterId());
- }
+ ClusterNodeInfoDocument me = missingLastRevUtil.getClusterNodeInfo(revisionContext.getClusterId());
if (me != null && me.isRecoveryNeeded(now)) {
log.warn("Own clusterId {} has a leaseEnd {} ({}) older than current time {} ({}). " +
"Refusing to run recovery on clusterId {}.",
@@ -163,6 +161,7 @@ public class LastRevRecoveryAgent {
clusterId);
return 0;
}
+ }
// Check if _lastRev recovery needed for this cluster node
// state is Active && current time past leaseEnd
if (nodeInfo.isRecoveryNeeded(now)) {
