From 2ff1516a941ec555b154d0a69586f27eea11d581 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Thu, 4 Apr 2024 23:43:53 +0200 Subject: [PATCH] Fix SearchWithRandomIOExceptionsIT tripping assertion in RefreshFieldHasValueListener We're in some cases tripping an assertion (`assertSearcherIsWarmedUp`) when we run the logic and no refresh actually happened because of induced exceptions. This really should only run if the refresh actually went through in any case. fixes #106752 --- .../src/main/java/org/elasticsearch/index/shard/IndexShard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 046483a6b074f..615bdbf23a45a 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -4003,7 +4003,7 @@ public void beforeRefresh() {} @Override public void afterRefresh(boolean didRefresh) { - if (enableFieldHasValue) { + if (enableFieldHasValue && didRefresh) { try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) { setFieldInfos(FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader())); } catch (AlreadyClosedException ignore) {