Skip to content

Commit

Permalink
Fix testPrepareIndexForPeerRecovery (#52245)
Browse files Browse the repository at this point in the history
Since #51905, we skip translog recovery if the local checkpoint of the 
safe commit equals to the global checkpoint. This change adjusts the
test not to create a new snapshot in that case.

Closes #52221
Relates #51905
  • Loading branch information
dnhatn authored Feb 12, 2020
1 parent a74ba9c commit 0c7ae02
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ public void testPrepareIndexForPeerRecovery() throws Exception {
Optional<SequenceNumbers.CommitInfo> safeCommit = shard.store().findSafeIndexCommit(globalCheckpoint);
assertTrue(safeCommit.isPresent());
int expectedTotalLocal = 0;
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
if (op.seqNo() <= globalCheckpoint) {
expectedTotalLocal++;
if (safeCommit.get().localCheckpoint < globalCheckpoint) {
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
if (op.seqNo() <= globalCheckpoint) {
expectedTotalLocal++;
}
}
}
}
Expand Down

0 comments on commit 0c7ae02

Please sign in to comment.