Skip to content

Commit d7fe135

Browse files
committed
Fix testPrepareIndexForPeerRecovery (#52245)
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
1 parent 82ab1bc commit d7fe135

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

server/src/test/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetServiceTests.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ public void testPrepareIndexForPeerRecovery() throws Exception {
177177
Optional<SequenceNumbers.CommitInfo> safeCommit = shard.store().findSafeIndexCommit(globalCheckpoint);
178178
assertTrue(safeCommit.isPresent());
179179
int expectedTotalLocal = 0;
180-
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
181-
Translog.Operation op;
182-
while ((op = snapshot.next()) != null) {
183-
if (op.seqNo() <= globalCheckpoint) {
184-
expectedTotalLocal++;
180+
if (safeCommit.get().localCheckpoint < globalCheckpoint) {
181+
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
182+
Translog.Operation op;
183+
while ((op = snapshot.next()) != null) {
184+
if (op.seqNo() <= globalCheckpoint) {
185+
expectedTotalLocal++;
186+
}
185187
}
186188
}
187189
}

0 commit comments

Comments
 (0)