Fix testRestoreLocalHistoryFromTranslog (#52441)
Asserts that no new operations are made into the translog since we re-opened the engine. Relates #51905 Closes #52410
This commit is contained in:
parent
a92bf5ec61
commit
5aa612c275
|
@ -4559,7 +4559,6 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
final EngineConfig engineConfig;
|
||||
final SeqNoStats prevSeqNoStats;
|
||||
final List<DocIdSeqNoAndSource> prevDocs;
|
||||
final List<Translog.Operation> existingTranslog;
|
||||
try (InternalEngine engine = createEngine(store, createTempDir(), globalCheckpoint::get)) {
|
||||
engineConfig = engine.config();
|
||||
for (final long seqNo : seqNos) {
|
||||
|
@ -4578,24 +4577,17 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
engine.syncTranslog();
|
||||
prevSeqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
||||
prevDocs = getDocIds(engine, true);
|
||||
try (Translog.Snapshot snapshot = engine.getTranslog().newSnapshot()) {
|
||||
existingTranslog = TestTranslog.drainSnapshot(snapshot, false);
|
||||
}
|
||||
}
|
||||
try (InternalEngine engine = new InternalEngine(engineConfig)) {
|
||||
final Translog.TranslogGeneration currrentTranslogGeneration = new Translog.TranslogGeneration(
|
||||
engine.getTranslog().getTranslogUUID(), engine.getTranslog().currentFileGeneration());
|
||||
final long currentTranslogGeneration = engine.getTranslog().currentFileGeneration();
|
||||
engine.recoverFromTranslog(translogHandler, globalCheckpoint.get());
|
||||
engine.restoreLocalHistoryFromTranslog(translogHandler);
|
||||
assertThat(getDocIds(engine, true), equalTo(prevDocs));
|
||||
SeqNoStats seqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
||||
assertThat(seqNoStats.getLocalCheckpoint(), equalTo(prevSeqNoStats.getLocalCheckpoint()));
|
||||
assertThat(seqNoStats.getMaxSeqNo(), equalTo(prevSeqNoStats.getMaxSeqNo()));
|
||||
try (Translog.Snapshot snapshot = engine.getTranslog().newSnapshot()) {
|
||||
assertThat("restore from local translog must not add operations to translog",
|
||||
snapshot.totalOperations(), equalTo(existingTranslog.size()));
|
||||
assertThat(TestTranslog.drainSnapshot(snapshot, false), equalTo(existingTranslog));
|
||||
}
|
||||
engine.getTranslog().totalOperationsByMinGen(currentTranslogGeneration), equalTo(0));
|
||||
}
|
||||
assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine, createMapperService("test"));
|
||||
}
|
||||
|
@ -6038,6 +6030,7 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
docs = getDocIds(engine, true);
|
||||
}
|
||||
try (InternalEngine engine = new InternalEngine(config)) {
|
||||
engine.onSettingsChanged(TimeValue.MINUS_ONE, ByteSizeValue.ZERO, 0);
|
||||
engine.recoverFromTranslog(translogHandler, Long.MAX_VALUE);
|
||||
assertThat(getDocIds(engine, randomBoolean()), equalTo(docs));
|
||||
if (engine.getSeqNoStats(globalCheckpoint.get()).getMaxSeqNo() == globalCheckpoint.get()) {
|
||||
|
|
Loading…
Reference in New Issue