From c4f6821b3a5be4e98e4155fff5750d781e37d92d Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Wed, 29 Jan 2020 16:27:33 -0500 Subject: [PATCH] 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 --- .../org/elasticsearch/index/engine/FrozenEngineTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java b/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java index 0334d3b198431..8e3c1295857ef 100644 --- a/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java +++ b/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java @@ -342,7 +342,9 @@ public void testSearchers() throws Exception { applyOperations(engine, generateHistoryOnReplica(between(10, 1000), false, randomBoolean(), randomBoolean())); globalCheckpoint.set(engine.getProcessedLocalCheckpoint()); 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"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { totalDocs = searcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs.length;