Why is a version conflict excpetion thrown when no versioning is used or required?

version_conflict_engine_exception

We're using ElasticSearch as a Cache and when we run a stress test with 10 processes simultaneously accessing and writing to ES we occasionally get a version_conflict_engine_exception exception. This is strange since we are not working with versions and do not provide a _version field. The last write should just win.

How can we avoid this problem or should we just ignore it?

We are using the NPM Package for ElasticSearch Client.

Request

PUT /mycache/_create/XYZ30034501 HTTP/1.1

{"part":"XYZ-30034-501","timestamp":"2019-09-27T06:23:09.209Z"}

Response

HTTP/1.1 409 Conflict
content-type: application/json; charset=UTF-8
content-length: 457

{
  "error": {
    "root_cause": [
      {
        "type": "version_conflict_engine_exception",
        "reason": "[XYZ30034501]: version conflict, document already exists (current version [1])",
        "index_uuid": "UoYuAeWUTiaIhJkYiPs72g",
        "shard": "0",
        "index": "partcache-dev1"
      }
    ],
    "type": "version_conflict_engine_exception",
    "reason": "[XYZ30034501]: version conflict, document already exists (current version [1])",
    "index_uuid": "UoYuAeWUTiaIhJkYiPs72g",
    "shard": "0",
    "index": "partcache-dev1"
  },
  "status": 409
}

You are using the _create API which returns 409 Conflict if the document already exists. Under the hood, this works by requiring the document version to be 0.

Switching to the client's index() method has solved this issue.

Many thanks David!

2 Likes

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