Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unlimited compilation rate limit for mustache templates in Ingest #64595

Closed
andrewkroh opened this issue Nov 4, 2020 · 10 comments · Fixed by #69841
Closed

Use unlimited compilation rate limit for mustache templates in Ingest #64595

andrewkroh opened this issue Nov 4, 2020 · 10 comments · Fixed by #69841
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team

Comments

@andrewkroh
Copy link
Member

In #59267 the compilation rate limit for the script and processor_conditional contexts was increased to unlimited. However some of the Ingest Node processors depend on mustache templates that are also scripts that need to be compiled. And those templates have their own separate rate limit. So users of Ingest Node pipelines can still hit limits. So I'd like to propose that templates also get an unlimited compilation rate in Ingest Node.

Here's an example of the type of error users see when using Filebeat modules or packages with Fleet:

Bulk item insert failed (i=5, status=500): {\"type\":\"illegal_state_exception\",\"reason\":\"pipeline with id [logs-system.auth-0.9.0] could not be loaded, caused by [ElasticsearchParseException[Error updating pipeline with id [logs-system.auth-0.9.0]]; nested: GeneralScriptException[Failed to compile inline script [{{system.auth.ssh.dropped_ip}}] using lang [mustache]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within, max: [75/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.context.template.max_compilations_rate] setting];; GeneralScriptException[Failed to compile inline script [{{system.auth.ssh.dropped_ip}}] using lang [mustache]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within, max: [75/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.context.template.max_compilations_rate] setting];; org.elasticsearch.common.breaker.CircuitBreakingException: [script] Too many dynamic script compilations within, max: [75/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.context.template.max_compilations_rate] setting]\"}",

@andrewkroh andrewkroh added >enhancement needs:triage Requires assignment of a team area label labels Nov 4, 2020
@jakelandis jakelandis added :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP and removed needs:triage Requires assignment of a team area label labels Nov 4, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Ingest)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Nov 4, 2020
@jakelandis jakelandis added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Nov 4, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Nov 4, 2020
@jakelandis
Copy link
Contributor

@jdconrad @stu-elastic - I believe that the fix here would be in TemplateScript, but that is used in quite a few places. Do you think that we should create a new ingest_template context (and use that in ingest node) and increase that context limit to unlimited ?

@stu-elastic
Copy link
Contributor

We plan on moving all non-search contexts to unlimited by 7.11.

@stu-elastic
Copy link
Contributor

#62899

@alexander-marquardt
Copy link

alexander-marquardt commented Nov 4, 2020

If the cache size is too small for the number of scripts that the client is running, then this can result in each script
being pushed out of the cache, and then recompiled shortly thereafter -- thereby causing this "too many script compilations". In this case, making the cache size bigger (so compiled scripts are not evicted from the cache) may be more beneficial than increasing the compilation limit.

I have seen setting the compilation limit to a large number crash a cluster if the real problem is that the script cache is too small. (related support case: 00599383)

@stu-elastic
Copy link
Contributor

stu-elastic commented Nov 4, 2020

All the compiled scripts are held onto by the ingest pipeline. I'll verify when I get to #62899 that templates are as well, but I believe they are.

Upshot is cache is irrelevant for ingest pipelines, they are never recompiled, they stay with the pipeline for it's lifetime.

@alexander-marquardt
Copy link

Good to know, thanks!

@rjernst rjernst added the needs:triage Requires assignment of a team area label label Dec 3, 2020
@jimczi jimczi removed the needs:triage Requires assignment of a team area label label Jan 12, 2021
@kesslerm
Copy link

It may be necessary to delete (optional?) and upload the ingest pipeline again if the above error occurs repeatedly for a given pipeline and does not react to changing the compilation settings of the cluster. This is likely due to the error already being stored in the pipeline.

@stu-elastic
Copy link
Contributor

If a pipeline definition hits a compilation limit, the pipeline will remember the error and will not function. The solution is to update the limit and then delete and add back the pipeline.

stu-elastic added a commit to stu-elastic/elasticsearch that referenced this issue Mar 2, 2021
Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: elastic#64595
stu-elastic added a commit that referenced this issue Mar 4, 2021
* Script: no compile rate limit for ingest templates

Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: #64595
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this issue Mar 4, 2021
Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: elastic#64595
Backport: 9370b1c
stu-elastic added a commit that referenced this issue Mar 4, 2021
Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: #64595
Backport: 9370b1c
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this issue Mar 10, 2021
…lastic#69987)

Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: elastic#64595
Backport: 9370b1c
stu-elastic added a commit that referenced this issue Mar 10, 2021
Scripts in ingest pipelines may be throttled on startup
or when beats starts up. This causes pipelines to be
stuck in a broken state.

Pipelines with many mustache templates are particularly impacted.

Removes the compilation rate limit for ingest templates by
creating a new context, `ingest_template`, with an unlimited
compilation rate limit.

Fixes: #64595
Backport: 9370b1c
easyice pushed a commit to easyice/elasticsearch that referenced this issue Mar 25, 2021
* Script: no compile rate limit for ingest templates

Remove the compilation rate limit for ingest templates.

Creates a new context, `ingest_template`, with an unlimited
compilation rate limit.

The `template` context is used in many places so it cannot be
exempted from rate limits.

Fixes: elastic#64595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants