@@ -4207,7 +4207,6 @@ public void testRestoreLocalHistoryFromTranslog() throws IOException {
42074207 final EngineConfig engineConfig ;
42084208 final SeqNoStats prevSeqNoStats ;
42094209 final List <DocIdSeqNoAndSource > prevDocs ;
4210- final List <Translog .Operation > existingTranslog ;
42114210 try (InternalEngine engine = createEngine (store , createTempDir (), globalCheckpoint ::get )) {
42124211 engineConfig = engine .config ();
42134212 for (final long seqNo : seqNos ) {
@@ -4226,24 +4225,17 @@ public void testRestoreLocalHistoryFromTranslog() throws IOException {
42264225 engine .syncTranslog ();
42274226 prevSeqNoStats = engine .getSeqNoStats (globalCheckpoint .get ());
42284227 prevDocs = getDocIds (engine , true );
4229- try (Translog .Snapshot snapshot = engine .getTranslog ().newSnapshot ()) {
4230- existingTranslog = TestTranslog .drainSnapshot (snapshot , false );
4231- }
42324228 }
42334229 try (InternalEngine engine = new InternalEngine (engineConfig )) {
4234- final Translog .TranslogGeneration currrentTranslogGeneration = new Translog .TranslogGeneration (
4235- engine .getTranslog ().getTranslogUUID (), engine .getTranslog ().currentFileGeneration ());
4230+ final long currentTranslogGeneration = engine .getTranslog ().currentFileGeneration ();
42364231 engine .recoverFromTranslog (translogHandler , globalCheckpoint .get ());
42374232 engine .restoreLocalHistoryFromTranslog (translogHandler );
42384233 assertThat (getDocIds (engine , true ), equalTo (prevDocs ));
42394234 SeqNoStats seqNoStats = engine .getSeqNoStats (globalCheckpoint .get ());
42404235 assertThat (seqNoStats .getLocalCheckpoint (), equalTo (prevSeqNoStats .getLocalCheckpoint ()));
42414236 assertThat (seqNoStats .getMaxSeqNo (), equalTo (prevSeqNoStats .getMaxSeqNo ()));
4242- try (Translog .Snapshot snapshot = engine .getTranslog ().newSnapshot ()) {
4243- assertThat ("restore from local translog must not add operations to translog" ,
4244- snapshot .totalOperations (), equalTo (existingTranslog .size ()));
4245- assertThat (TestTranslog .drainSnapshot (snapshot , false ), equalTo (existingTranslog ));
4246- }
4237+ assertThat ("restore from local translog must not add operations to translog" ,
4238+ engine .getTranslog ().totalOperationsByMinGen (currentTranslogGeneration ), equalTo (0 ));
42474239 }
42484240 assertConsistentHistoryBetweenTranslogAndLuceneIndex (engine , createMapperService ());
42494241 }
0 commit comments