ElasticSearch Inline script compilation circuit breaker triggered on static script code

Using java rest api I submit bulk update requests with painless script

for (entry in params.entrySet()) {ctx._source[entry.getKey()] = entry.getValue();}

Occasionally I get dynamic compilation circuit breaker triggering on such updates.

Considering it is the only script we use I fail to understand why it would not compile once and get cached.

I am on rather old version of ES 7.2.0

I've changed the script to be stored in hopes it would be compiled once. But even stored script fails with dynamic compilation circuit breaker exception.

Elasticsearch exception [type=illegal_argument_exception, reason=failed to execute script]","caused_by":{"type":"exception","reason":"Elasticsearch excepti
on [type=general_script_exception, reason=Failed to compile stored script [replace_field_values] using lang [painless]]","caused_by":{"type":"exception","reason":"Elasticsearch exception [type=circuit_breaking_exception, reason=[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.max_compilations_rate] setting]","durability":"TRANSIENT"}}},"status":400}]

Apparently well behaved stored scripts can suffer from being evicted from cache and requiring compilation by other not so well behaved scripts. I did hope that stored scripts would be isolated in that regard but no such luck.

My service is using stored scripts and they were evicted by dynamically generated scripts from a different service on shared ElasticSearch instance. Cache limits per client would do the trick too. Oh well.

I assume cache churn is caused by using simple LRUCache - I wonder if Window TinyLFU (W-TinyLFU) eviction policy would give you a better result - well behaved scripts will not be affected by poorly designed dynamic scripts.
Solr has already switched to use GitHub - ben-manes/caffeine: A high performance caching library for Java as default recommended cache due to better caching stats

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.