# Painless stored script "dynamic" compile error

**URL:** <https://discuss.elastic.co/t/painless-stored-script-dynamic-compile-error/318357>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 7, 2022, 5:02pm UTC](https://discuss.elastic.co/t/painless-stored-script-dynamic-compile-error/318357 "2022-11-07T17:02:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karasick](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karasick/32/113057_2.png) [@karasick](https://discuss.elastic.co/u/karasick)\
**Post date:** [November 7, 2022, 5:02pm UTC](https://discuss.elastic.co/t/painless-stored-script-dynamic-compile-error/318357/1 "2022-11-07T17:02:36Z")

</div>

Can someone please explain to me the next error ?

```auto
"error": {
          "type": "illegal_argument_exception",
          "reason": "failed to execute script",
          "caused_by": {
            "type": "general_script_exception",
            "reason": "Failed to compile stored script [simple-test-script] using lang [painless]",
            "caused_by": {
              "type": "circuit_breaking_exception",
              "reason": "[script] Too many dynamic script compilations within, max: [1/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.context.update.max_compilations_rate] setting",
              "bytes_wanted": 0,
              "bytes_limit": 0,
              "durability": "TRANSIENT"
            }
          }
        }

```

To reproduce it you can easily follow the next steps on Elastic Cloud:

```auto
PUT _cluster/settings
{
    "persistent": {
        "script.context.update.max_compilations_rate": "1/5m"
    }
}

PUT /_scripts/simple-test-script
{
  "script": {
    "lang": "painless",
    "source": """
        ctx._source['test_field'] = 'test value'
    """
  }
}

PUT /test-index

POST /test-index/_bulk
{"update":{"_id":"1"}}
{"script":{"id": "simple-test-script"}, "upsert": {}, "scripted_upsert": true}
{"update":{"_id":"2"}}
{"script":{"id": "simple-test-script"}, "upsert": {}, "scripted_upsert": true}

```

Why does _simple-test-script_ dynamic at this point ? And what does _dynamic_ mean in this situation ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 5, 2022, 5:03pm UTC](https://discuss.elastic.co/t/painless-stored-script-dynamic-compile-error/318357/2 "2022-12-05T17:03:03Z")

</div>

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