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;