elasticsearch
runtime_error
ai_generated
true
脚本异常:脚本 [my_script] 编译失败:一分钟内动态脚本编译次数过多
ScriptException: compilation of script [my_script] failed: too many dynamic script compilations within one minute
ID: elasticsearch/script-compilation-too-many-dynamic
80%修复率
87%置信度
1证据数
2024-04-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.17.14 | active | — | — | — |
| 8.5.3 | active | — | — | — |
| 8.12.0 | active | — | — | — |
根因分析
集群的脚本编译速率超过了 script.max_compilations_rate 限制,通常是因为每个查询生成唯一脚本而不是使用缓存脚本。
English
The cluster's script compilation rate exceeds the script.max_compilations_rate limit, typically due to generating unique scripts per query instead of using cached scripts.
官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/scripting.html解决方案
-
使用存储脚本代替内联脚本:POST _scripts/my_script { "script": { "lang": "painless", "source": "doc['field'].value * params.factor" } } 然后在查询中引用为 "script": { "id": "my_script", "params": { "factor": 2 } } -
临时增加编译速率限制:PUT /_cluster/settings { "transient": { "script.max_compilations_rate": "100/1m" } }
无效尝试
常见但无效的做法:
-
85% 失败
Unlimited compilations can lead to high CPU usage, memory pressure, and potential denial of service.
-
70% 失败
This only delays the problem; if scripts are not cached, the rate will still be hit eventually with high load.