Relax translog assertion in testRestoreLocalHistoryFromTranslog (#45943)
Since #45473, we trim translog below the local checkpoint of the safe commit immediately if soft-deletes enabled. In testRestoreLocalHistoryFromTranslog, we should have a safe commit after recoverFromTranslog is called; then we will trim translog files which contain only operations that are at most the global checkpoint. With this change, we relax the assertion to ensure that we don't put operations to translog while recovering history from the local translog.
This commit is contained in:
parent
c66bae39c3
commit
146e23a8a9
|
@ -4507,7 +4507,6 @@ public class InternalEngineTests extends EngineTestCase {
|
||||||
final EngineConfig engineConfig;
|
final EngineConfig engineConfig;
|
||||||
final SeqNoStats prevSeqNoStats;
|
final SeqNoStats prevSeqNoStats;
|
||||||
final List<DocIdSeqNoAndSource> prevDocs;
|
final List<DocIdSeqNoAndSource> prevDocs;
|
||||||
final int totalTranslogOps;
|
|
||||||
try (InternalEngine engine = createEngine(store, createTempDir(), globalCheckpoint::get)) {
|
try (InternalEngine engine = createEngine(store, createTempDir(), globalCheckpoint::get)) {
|
||||||
engineConfig = engine.config();
|
engineConfig = engine.config();
|
||||||
for (final long seqNo : seqNos) {
|
for (final long seqNo : seqNos) {
|
||||||
|
@ -4526,16 +4525,19 @@ public class InternalEngineTests extends EngineTestCase {
|
||||||
engine.syncTranslog();
|
engine.syncTranslog();
|
||||||
prevSeqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
prevSeqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
||||||
prevDocs = getDocIds(engine, true);
|
prevDocs = getDocIds(engine, true);
|
||||||
totalTranslogOps = engine.getTranslog().totalOperations();
|
|
||||||
}
|
}
|
||||||
try (InternalEngine engine = new InternalEngine(engineConfig)) {
|
try (InternalEngine engine = new InternalEngine(engineConfig)) {
|
||||||
|
final Translog.TranslogGeneration currrentTranslogGeneration = new Translog.TranslogGeneration(
|
||||||
|
engine.getTranslog().getTranslogUUID(), engine.getTranslog().currentFileGeneration());
|
||||||
engine.recoverFromTranslog(translogHandler, globalCheckpoint.get());
|
engine.recoverFromTranslog(translogHandler, globalCheckpoint.get());
|
||||||
engine.restoreLocalHistoryFromTranslog(translogHandler);
|
engine.restoreLocalHistoryFromTranslog(translogHandler);
|
||||||
assertThat(getDocIds(engine, true), equalTo(prevDocs));
|
assertThat(getDocIds(engine, true), equalTo(prevDocs));
|
||||||
SeqNoStats seqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
SeqNoStats seqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
||||||
assertThat(seqNoStats.getLocalCheckpoint(), equalTo(prevSeqNoStats.getLocalCheckpoint()));
|
assertThat(seqNoStats.getLocalCheckpoint(), equalTo(prevSeqNoStats.getLocalCheckpoint()));
|
||||||
assertThat(seqNoStats.getMaxSeqNo(), equalTo(prevSeqNoStats.getMaxSeqNo()));
|
assertThat(seqNoStats.getMaxSeqNo(), equalTo(prevSeqNoStats.getMaxSeqNo()));
|
||||||
assertThat(engine.getTranslog().totalOperations(), equalTo(totalTranslogOps));
|
try (Translog.Snapshot snapshot = engine.getTranslog().newSnapshotFromGen(currrentTranslogGeneration, Long.MAX_VALUE)) {
|
||||||
|
assertThat("restore from local translog must not add operations to translog", snapshot, SnapshotMatchers.size(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine, createMapperService("test"));
|
assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine, createMapperService("test"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue