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
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.