Skip to content

[Feature Request] Dynamically update maxClauseCount based on resources on a node #12549

Closed
@harshavamsi

Description

@harshavamsi

Is your feature request related to a problem? Please describe

Today lucene has a concept of max_clause_count which prevents the number of clauses from exceeding when expanding wildcard and prefix queries. OpenSearch inherited ES 7.10 which used a static index.query.bool.max_clause_count setting that is set to a max of 1024 by default.

In https://issues.apache.org/jira/browse/LUCENE-8811, lucene changed the clause count from affecting only boolean queries to all queries on the index by adding the constraint at the indexSearcher level. This means that the expansion effects all the fields and is now very easy to cross the limit.

A workaround was to use a rewrite to avoid hitting that limit, but it no longer works since the number of clauses after a rewrite is now what is counted.

A lot of users trying to migrate from OS 1.x to 2.x have reported this problem where their queries would previously not hit the clause limit, but since upgrading have now run into the limits. ElasticSearch themselves have updated the way that the limit is computed and moved away from a static limit of 1024 to a more dynamic resource based(thread pool and heap size) limit.

Graylog2/graylog2-server#14272 is an example of people running into this issue.

Describe the solution you'd like

Rather than relying on INDICES_MAX_CLAUSE_COUNT_SETTING from cluster settings, compute threadpool and heap sizes from jvm stats and use them to determine clause limit.

Is there a better metric to compute them? The limit was introduced to prevent rouge queries from consuming too many threads, CPU, and memory. It would make sense to update the limit based on these attributes.

Related component

Search:Resiliency

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Search:ResiliencyenhancementEnhancement or improvement to existing feature or requestv2.16.0Issues and PRs related to version 2.16.0v3.0.0Issues and PRs related to version 3.0.0

    Type

    No type

    Projects

    Status

    ✅ Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions