Skip to content

Commit

Permalink
Handled recovery to start from lowest seqno if pruning is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
saikaranam-amazon committed Sep 6, 2021
1 parent acd09db commit 6c546a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,24 @@ && isTargetSameHistory()
// advances and not when creating a new safe commit. In any case this is a best-effort thing since future recoveries can
// always fall back to file-based ones, and only really presents a problem if this primary fails before things have settled
// down.
startingSeqNo = softDeletesEnabled
? Long.parseLong(safeCommitRef.getIndexCommit().getUserData().get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)) + 1L
: 0;
if(softDeletesEnabled) {
final long minimumRetainingSequenceNumber = shard.getRetentionLeases()
.leases()
.stream()
.mapToLong(RetentionLease::retainingSequenceNumber)
.min()
.orElse(Long.MAX_VALUE);
final long safeCommitSeqNo = Long.parseLong(safeCommitRef.getIndexCommit()
.getUserData().get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)) + 1L;
if(shard.indexSettings().shouldPruneTranslogByRetentionLease()) {
startingSeqNo = SequenceNumbers.min(safeCommitSeqNo, minimumRetainingSequenceNumber);
} else {
startingSeqNo = safeCommitSeqNo;
}
} else {
startingSeqNo = 0;
}
logger.trace("performing file-based recovery followed by history replay starting at [{}]", startingSeqNo);

try {
final int estimateNumOps = shard.estimateNumberOfHistoryOperations("peer-recovery", historySource, startingSeqNo);
final Releasable releaseStore = acquireStore(shard.store());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public void testBytesRetention() throws IOException {
}
}

public void testBytesRetentionWithRetentionLease() throws Exception {
long now = System.currentTimeMillis();

}

public void testAgeRetention() throws IOException {
long now = System.currentTimeMillis();
Tuple<List<TranslogReader>, TranslogWriter> readersAndWriter = createReadersAndWriter(now);
Expand Down

0 comments on commit 6c546a3

Please sign in to comment.