{"action":"closed","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/16783","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16783/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16783/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16783/events","html_url":"https://github.com/elastic/elasticsearch/issues/16783","id":135833908,"number":16783,"title":"Implement stronger external versioning scheme","user":{"login":"koenoki","id":5985690,"avatar_url":"https://avatars.githubusercontent.com/u/5985690?v=3","gravatar_id":"","url":"https://api.github.com/users/koenoki","html_url":"https://github.com/koenoki","followers_url":"https://api.github.com/users/koenoki/followers","following_url":"https://api.github.com/users/koenoki/following{/other_user}","gists_url":"https://api.github.com/users/koenoki/gists{/gist_id}","starred_url":"https://api.github.com/users/koenoki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koenoki/subscriptions","organizations_url":"https://api.github.com/users/koenoki/orgs","repos_url":"https://api.github.com/users/koenoki/repos","events_url":"https://api.github.com/users/koenoki/events{/privacy}","received_events_url":"https://api.github.com/users/koenoki/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-23T19:14:29Z","updated_at":"2016-02-24T19:59:56Z","closed_at":"2016-02-24T19:59:56Z","body":"Per https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html: \"Elasticsearch checks that the current _version is less than the specified version\". This still leaves room for concurrency issues. Eg:\r\n\r\n1. Client A reads a document with version V0\r\n2. Client B reads the same document, version V0\r\n3. Client A writes back the document as version V1\r\n4. Client B writes back the document as version V2\r\n\r\nIn the above example, the last write can overwrite the change made by client A. This does not happen with the regular (non-external) versioning scheme. In order to do full versioning check, the system needs to know both the previous version and the new version. \r\n\r\nSo, can we allow optionally specifying the previous version in the PUT request? Eg:\r\n\r\nPUT /website/blog/2?version=5&prev_version=3&version_type=external\r\n\r\nIf prev_version is unspecified then ES behaves as it does today. But if it is specified then ES should check if the current _version matches the specified prev_version, as opposed to checking if the current _version is less than the new version."}}