Skip to content

Commit 60f8941

Browse files
authored
Fix Translog#testWithRandomException (#51712)
Before #51417, trimUnreferencedReaders in this test was a noop as the default translog retention policy was 512MB and 12h, which was long enough to keep all translog files. Two problems in this test: - We do not consider any failure while trimming unreferenced readers as a tragedy. - We should clear the synced list before calling trimUnreferencedReaders. Relates #51505 Closes #51694
1 parent 40f0a26 commit 60f8941

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,9 +2657,9 @@ public void testWithRandomException() throws IOException {
26572657
committing = true;
26582658
failableTLog.getDeletionPolicy().setTranslogGenerationOfLastCommit(failableTLog.currentFileGeneration());
26592659
failableTLog.getDeletionPolicy().setMinTranslogGenerationForRecovery(failableTLog.currentFileGeneration());
2660+
syncedDocs.clear();
26602661
failableTLog.trimUnreferencedReaders();
26612662
committing = false;
2662-
syncedDocs.clear();
26632663
}
26642664
}
26652665
// we survived all the randomness!!!
@@ -2675,7 +2675,7 @@ public void testWithRandomException() throws IOException {
26752675
assertEquals(failableTLog.getTragicException(), ex);
26762676
} catch (RuntimeException ex) {
26772677
assertEquals(ex.getMessage(), "simulated");
2678-
assertEquals(failableTLog.getTragicException(), ex);
2678+
assertNull("Don't consider failures while trimming unreferenced readers as tragedy", failableTLog.getTragicException());
26792679
} finally {
26802680
Checkpoint checkpoint = Translog.readCheckpoint(config.getTranslogPath());
26812681
if (checkpoint.numOps == unsynced.size() + syncedDocs.size()) {

0 commit comments

Comments
 (0)