Force flush in FrozenEngine#testSearchers (#51635)

We need to force flush to make the last commit safe; otherwise, we might 
fail to open FrozenEngine. Note that we force flush before closing a
shard.

Closes #51620
This commit is contained in:
Nhat Nguyen 2020-01-29 16:27:33 -05:00
parent 72c5bc9630
commit 1cba5d7c4b

View File

@ -342,7 +342,9 @@ public class FrozenEngineTests extends EngineTestCase {
applyOperations(engine, generateHistoryOnReplica(between(10, 1000), false, randomBoolean(), randomBoolean())); applyOperations(engine, generateHistoryOnReplica(between(10, 1000), false, randomBoolean(), randomBoolean()));
globalCheckpoint.set(engine.getProcessedLocalCheckpoint()); globalCheckpoint.set(engine.getProcessedLocalCheckpoint());
engine.syncTranslog(); engine.syncTranslog();
engine.flush(); // We need to force flush to make the last commit a safe commit; otherwise, we might fail to open ReadOnlyEngine
// See TransportVerifyShardBeforeCloseAction#executeShardOperation
engine.flush(true, true);
engine.refresh("test"); engine.refresh("test");
try (Engine.Searcher searcher = engine.acquireSearcher("test")) { try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
totalDocs = searcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs.length; totalDocs = searcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs.length;