Skip to content

Commit 64fb588

Browse files
Fix SearchWithRandomIOExceptionsIT tripping assertion in RefreshFieldHasValueListener (elastic#107128) (elastic#113826)
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 elastic#106752
1 parent 7d02f5c commit 64fb588

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
4242
return Arrays.asList(MockFSIndexStore.TestPlugin.class);
4343
}
4444

45-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/106752")
4645
public void testRandomDirectoryIOExceptions() throws IOException, InterruptedException, ExecutionException {
4746
String mapping = Strings.toString(
4847
XContentFactory.jsonBuilder()

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
231231

232232
// sys prop to disable the field has value feature, defaults to true (enabled) if set to false (disabled) the
233233
// field caps always returns empty fields ignoring the value of the query param `field_caps_empty_fields_filter`.
234-
private final boolean enableFieldHasValue = Booleans.parseBoolean(
234+
private static final boolean enableFieldHasValue = Booleans.parseBoolean(
235235
System.getProperty("es.field_caps_empty_fields_filter", Boolean.TRUE.toString())
236236
);
237237

@@ -4065,7 +4065,7 @@ public void beforeRefresh() {}
40654065

40664066
@Override
40674067
public void afterRefresh(boolean didRefresh) {
4068-
if (enableFieldHasValue) {
4068+
if (enableFieldHasValue && (didRefresh || fieldInfos == FieldInfos.EMPTY)) {
40694069
try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) {
40704070
setFieldInfos(FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader()));
40714071
} catch (AlreadyClosedException ignore) {

0 commit comments

Comments
 (0)