@@ -92,11 +92,21 @@ static void corruptRandomTranslogFile(Logger logger, Random random, Path translo
92
92
// if we crashed while rolling a generation then we might have copied `translog.ckp` to its numbered generation file but
93
93
// have not yet written a new `translog.ckp`. During recovery we must also verify that this file is intact, so it's ok to
94
94
// corrupt this file too (either by writing the wrong information, correctly formatted, or by properly corrupting it)
95
- final Checkpoint checkpointCopy = LuceneTestCase .usually (random ) ? checkpoint
96
- : new Checkpoint (checkpoint .offset + random .nextInt (2 ), checkpoint .numOps + random .nextInt (2 ),
97
- checkpoint .generation + random .nextInt (2 ), checkpoint .minSeqNo + random .nextInt (2 ),
98
- checkpoint .maxSeqNo + random .nextInt (2 ), checkpoint .globalCheckpoint + random .nextInt (2 ),
99
- checkpoint .minTranslogGeneration + random .nextInt (2 ), checkpoint .trimmedAboveSeqNo + random .nextInt (2 ));
95
+ final Checkpoint checkpointCopy ;
96
+ if (LuceneTestCase .usually (random )) {
97
+ checkpointCopy = checkpoint ;
98
+ } else {
99
+ long newTranslogGeneration = checkpoint .generation + random .nextInt (2 );
100
+ long newMinTranslogGeneration = Math .min (newTranslogGeneration , checkpoint .minTranslogGeneration + random .nextInt (2 ));
101
+ long newMaxSeqNo = checkpoint .maxSeqNo + random .nextInt (2 );
102
+ long newMinSeqNo = Math .min (newMaxSeqNo , checkpoint .minSeqNo + random .nextInt (2 ));
103
+ long newTrimmedAboveSeqNo = Math .min (newMaxSeqNo , checkpoint .trimmedAboveSeqNo + random .nextInt (2 ));
104
+
105
+ checkpointCopy = new Checkpoint (checkpoint .offset + random .nextInt (2 ), checkpoint .numOps + random .nextInt (2 ),
106
+ newTranslogGeneration , newMinSeqNo ,
107
+ newMaxSeqNo , checkpoint .globalCheckpoint + random .nextInt (2 ),
108
+ newMinTranslogGeneration , newTrimmedAboveSeqNo );
109
+ }
100
110
Checkpoint .write (FileChannel ::open , unnecessaryCheckpointCopyPath , checkpointCopy ,
101
111
StandardOpenOption .WRITE , StandardOpenOption .CREATE_NEW );
102
112
0 commit comments