Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11284: Greedy Reuse of cluster IDs may lead to synchronous LastRe… #1877

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.isCommitted;
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand All @@ -45,6 +47,7 @@
import org.apache.jackrabbit.guava.common.collect.Sets;

import org.apache.jackrabbit.oak.commons.TimeDurationFormatter;
import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier;
import org.apache.jackrabbit.oak.plugins.document.bundlor.DocumentBundlor;
import org.apache.jackrabbit.oak.plugins.document.cache.CacheInvalidationStats;
import org.apache.jackrabbit.oak.plugins.document.util.MapFactory;
Expand Down Expand Up @@ -79,6 +82,8 @@ public class LastRevRecoveryAgent {

private final Consumer<Integer> afterRecovery;

private static final SystemPropertySupplier<Long> SYNC_RECOVERY_TIMEOUT_MILLIS = SystemPropertySupplier.create("oak.syncRecoveryTimeoutMillis", Long.MAX_VALUE);

private static final long LOGINTERVALMS = TimeUnit.MINUTES.toMillis(1);

// OAK-9535 : create (flush) a pseudo branch commit journal entry as soon as
Expand Down Expand Up @@ -268,6 +273,11 @@ public int recover(final Iterable<NodeDocument> suspects,
if (nodeInfo != null && nodeInfo.isActive()) {
deadline = nodeInfo.getLeaseEndTime() - ClusterNodeInfo.DEFAULT_LEASE_FAILURE_MARGIN_MILLIS;
}
long now = System.currentTimeMillis();
if (Long.MAX_VALUE - SYNC_RECOVERY_TIMEOUT_MILLIS.get() > now) {
deadline = Math.min(deadline, now + SYNC_RECOVERY_TIMEOUT_MILLIS.get());
log.info("Adjusted deadline for synchronous recovery. New deadline is {}", SimpleDateFormat.getDateTimeInstance().format(new Date(deadline)));
}
mbaedke marked this conversation as resolved.
Show resolved Hide resolved
}

NodeDocument rootDoc = Utils.getRootDocument(store);
Expand Down