Skip to content

Commit

Permalink
Fix bitset filter cache loading in Stateless
Browse files Browse the repository at this point in the history
As recognized in PR elastic#113478 reviewing, the bitset filter cache
was wrongly eagerly loaded only for fast refresh indices on index
nodes. However, it should be eagerly loaded for any index that
can be searched. This PR fixes this.
  • Loading branch information
kingherc committed Oct 6, 2024
1 parent 6535bda commit c9e4a56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,14 @@ static boolean shouldLoadRandomAccessFiltersEagerly(IndexSettings settings) {
boolean loadFiltersEagerlySetting = settings.getValue(INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING);
boolean isStateless = DiscoveryNode.isStateless(settings.getNodeSettings());
if (isStateless) {
return DiscoveryNode.hasRole(settings.getNodeSettings(), DiscoveryNodeRole.INDEX_ROLE)
&& loadFiltersEagerlySetting
&& INDEX_FAST_REFRESH_SETTING.get(settings.getSettings());
// We would like to eagerly load filters when the index can get searched. In Stateless, searches can happen on a search node
// for regular non-fast-refresh indices, or on an index node for fast refresh indices.
boolean fastRefreshIndex = INDEX_FAST_REFRESH_SETTING.get(settings.getSettings());
boolean fastRefreshIndexOnIndexNode = fastRefreshIndex
&& DiscoveryNode.hasRole(settings.getNodeSettings(), DiscoveryNodeRole.INDEX_ROLE);
boolean nonFastRefreshIndexOnSearchNode = (fastRefreshIndex == false)
&& DiscoveryNode.hasRole(settings.getNodeSettings(), DiscoveryNodeRole.SEARCH_ROLE);
return loadFiltersEagerlySetting && (fastRefreshIndexOnIndexNode || nonFastRefreshIndexOnSearchNode);
} else {
return loadFiltersEagerlySetting;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public void testShouldLoadRandomAccessFiltersEagerly() {
for (var isStateless : values) {
if (isStateless) {
assertEquals(
loadFiltersEagerly && indexFastRefresh && hasIndexRole,
loadFiltersEagerly
&& ((indexFastRefresh && hasIndexRole) || (indexFastRefresh == false && hasIndexRole == false)),
BitsetFilterCache.shouldLoadRandomAccessFiltersEagerly(
bitsetFilterCacheSettings(isStateless, hasIndexRole, loadFiltersEagerly, indexFastRefresh)
)
Expand Down

0 comments on commit c9e4a56

Please sign in to comment.