{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6431","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6431/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6431/comments","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6431/events","html_url":"https://github.com/elasticsearch/elasticsearch/issues/6431","id":35148313,"number":6431,"title":"Check-and-set for aliases","user":{"login":"magnhaug","id":477436,"avatar_url":"https://avatars.githubusercontent.com/u/477436?v=3","gravatar_id":"","url":"https://api.github.com/users/magnhaug","html_url":"https://github.com/magnhaug","followers_url":"https://api.github.com/users/magnhaug/followers","following_url":"https://api.github.com/users/magnhaug/following{/other_user}","gists_url":"https://api.github.com/users/magnhaug/gists{/gist_id}","starred_url":"https://api.github.com/users/magnhaug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magnhaug/subscriptions","organizations_url":"https://api.github.com/users/magnhaug/orgs","repos_url":"https://api.github.com/users/magnhaug/repos","events_url":"https://api.github.com/users/magnhaug/events{/privacy}","received_events_url":"https://api.github.com/users/magnhaug/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/feedback_needed","name":"feedback_needed","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-06-06T14:06:56Z","updated_at":"2015-01-05T11:37:30Z","closed_at":null,"body":"The atomic update of aliases is very useful. However, if you have aggregate aliases that point to a lot of indexes, and these indexes are managed by a different threads/processes, you risk running into race conditions on updates.\r\n\r\nI'd like this application flow:\r\n - Read which aliases to update\r\n - Issue the correct deletes and adds, *given the current situation is as expected*\r\n - Full *rollback*, and the ability to retry if the situation had changed from what we asserted\r\n\r\nThis would remove the need to synchronize complex alias operations in a multi-thread environment.\r\n\r\nIn the Java API I'd wish for something like:\r\n - .addAlias(index, alias)\r\n - .removeAlias(index, alias)\r\n - *.assertAlias(index, alias)*  or similar"},"comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/comments/68697358","html_url":"https://github.com/elasticsearch/elasticsearch/issues/6431#issuecomment-68697358","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6431","id":68697358,"user":{"login":"clintongormley","id":56599,"avatar_url":"https://avatars.githubusercontent.com/u/56599?v=3","gravatar_id":"","url":"https://api.github.com/users/clintongormley","html_url":"https://github.com/clintongormley","followers_url":"https://api.github.com/users/clintongormley/followers","following_url":"https://api.github.com/users/clintongormley/following{/other_user}","gists_url":"https://api.github.com/users/clintongormley/gists{/gist_id}","starred_url":"https://api.github.com/users/clintongormley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintongormley/subscriptions","organizations_url":"https://api.github.com/users/clintongormley/orgs","repos_url":"https://api.github.com/users/clintongormley/repos","events_url":"https://api.github.com/users/clintongormley/events{/privacy}","received_events_url":"https://api.github.com/users/clintongormley/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T11:37:30Z","updated_at":"2015-01-05T11:37:30Z","body":"Hi @magnhaug \r\n\r\nThanks for the info.  I'll put this issue up for discussion, but my feeling is that it is the wrong approach.  Once you start with assertions like this, then where does it end?  Should we also assert on routing values, or alias filters?  What about other indices that an alias might point to?  It starts getting really messy.\r\n\r\nTypically updating aliases is a very light-weight operation, so serialising requests application side is pretty easy.  Also, I'm working on a proposal for a more event-driven framework which will allow you to specify actions to be taken on certain cluster events (eg the creation of a new index).  i think this will be a cleaner solution than the assertions."}}