Skip to content

Commit

Permalink
Fix SearchWithRandomIOExceptionsIT tripping assertion in RefreshField…
Browse files Browse the repository at this point in the history
…HasValueListener (#107128)

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
  • Loading branch information
original-brownbear committed Sep 30, 2024
1 parent 8cb1266 commit 675087a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(MockFSIndexStore.TestPlugin.class);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/106752")
public void testRandomDirectoryIOExceptions() throws IOException, InterruptedException, ExecutionException {
String mapping = Strings.toString(
XContentFactory.jsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl

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

Expand Down Expand Up @@ -4080,7 +4080,7 @@ public void beforeRefresh() {}

@Override
public void afterRefresh(boolean didRefresh) {
if (enableFieldHasValue) {
if (enableFieldHasValue && (didRefresh || fieldInfos == FieldInfos.EMPTY)) {
try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) {
setFieldInfos(FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader()));
} catch (AlreadyClosedException ignore) {
Expand Down

0 comments on commit 675087a

Please sign in to comment.