diff --git a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 636dca207a8..2a988e15bf8 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -1718,13 +1718,20 @@ public class InternalEngine extends Engine { try { // Only flush if (1) Lucene has uncommitted docs, or (2) forced by caller, or (3) the // newly created commit points to a different translog generation (can free translog) - if (indexWriter.hasUncommittedChanges() || force || shouldPeriodicallyFlush()) { + boolean hasUncommittedChanges = indexWriter.hasUncommittedChanges(); + boolean shouldPeriodicallyFlush = shouldPeriodicallyFlush(); + if (hasUncommittedChanges || force || shouldPeriodicallyFlush) { ensureCanFlush(); try { translog.rollGeneration(); logger.trace("starting commit for flush; commitTranslog=true"); commitIndexWriter(indexWriter, translog, null); logger.trace("finished commit for flush"); + + // a temporary debugging to investigate test failure - issue#32827. Remove when the issue is resolved + logger.debug("new commit on flush, hasUncommittedChanges:{}, force:{}, shouldPeriodicallyFlush:{}", + hasUncommittedChanges, force, shouldPeriodicallyFlush); + // we need to refresh in order to clear older version values refresh("version_table_flush", SearcherScope.INTERNAL, true); translog.trimUnreferencedReaders(); diff --git a/server/src/test/java/org/elasticsearch/indices/IndicesRequestCacheIT.java b/server/src/test/java/org/elasticsearch/indices/IndicesRequestCacheIT.java index 90909b1c201..7995c5f5052 100644 --- a/server/src/test/java/org/elasticsearch/indices/IndicesRequestCacheIT.java +++ b/server/src/test/java/org/elasticsearch/indices/IndicesRequestCacheIT.java @@ -51,7 +51,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSear import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -@TestLogging(value = "org.elasticsearch.indices.IndicesRequestCache:TRACE") +@TestLogging(value = "org.elasticsearch.indices.IndicesRequestCache:TRACE,org.elasticsearch.index.engine.Engine:DEBUG") public class IndicesRequestCacheIT extends ESIntegTestCase { // One of the primary purposes of the query cache is to cache aggs results