Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testRestoreLocalHistoryFromTranslog #52441

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4207,7 +4207,6 @@ public void testRestoreLocalHistoryFromTranslog() throws IOException {
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) {
Expand All @@ -4226,24 +4225,17 @@ public void testRestoreLocalHistoryFromTranslog() throws IOException {
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));
}
assertThat("restore from local translog must not add operations to translog",
engine.getTranslog().totalOperationsByMinGen(currentTranslogGeneration), equalTo(0));
}
assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine, createMapperService());
}
Expand Down