Execute enrich policy always blocks until complete. Improve documentation or bug?

See execute-enrich-policy-api-query-params wait_for_completion

I am running Elasticsearch version 7.17.2 and this part of the documentation is a bit confusing

wait_for_completion
    (Required, Boolean) If true, the request blocks other enrich policy execution requests until complete. Defaults to true.

When I execute a enrich policy twice in a row with wait_for_completion=false I expected that the second invocation would not block according to this documentation. However, the second invocation returns a status 429 - too many requests. I assume that the request is "blocked" when I receive that status. Is this a bug or is it just the documentation that needs a update? Why is not the obvious effect better documented, that is that the request returns before the task is completed with a taskid when wait_for_completion=false?

PUT /_enrich/policy/my-policy/_execute?wait_for_completion=false

The only difference seems to be that wait_for_completion=false returns before it is completed with a taskid while wait_for_completion=true returns a response when it has been completed (unless there is an error ofc).

There is also no documentation of the different type of responses that is returned

PUT /_enrich/policy/my-policy/_execute?wait_for_completion=false

returns before task is completed a taskid

{
  "task" : "-q20J8U_SGOFg0d4CFXceg:39550"
}
PUT /_enrich/policy/my-policy/_execute?wait_for_completion=true

returns

{
  "status" : {
    "phase" : "COMPLETE"
  }
}

How to produce a "block" or 429 response
Do a

PUT /_enrich/policy/my-policy/_execute?wait_for_completion=false

then immediately follow up with

PUT /_enrich/policy/my-policy/_execute?wait_for_completion=true

or

PUT /_enrich/policy/my-policy/_execute?wait_for_completion=false

to get the response

{
  "error" : {
    "root_cause" : [
      {
        "type" : "es_rejected_execution_exception",
        "reason" : "Could not obtain lock because policy execution for [my-policy] is already in progress."
      }
    ],
    "type" : "es_rejected_execution_exception",
    "reason" : "Could not obtain lock because policy execution for [my-policy] is already in progress."
  },
  "status" : 429
}

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