{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/8688","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/8688/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/8688/comments","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/8688/events","html_url":"https://github.com/elasticsearch/elasticsearch/issues/8688","id":50310350,"number":8688,"title":"Mapping updates should be synchronous","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},"labels":[{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/:Mapping","name":":Mapping","color":"009800"},{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/enhancement","name":"enhancement","color":"4a4ea8"},{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/resiliency","name":"resiliency","color":"009800"},{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/v2.0.0","name":"v2.0.0","color":"dddddd"}],"state":"open","locked":false,"assignee":{"login":"rjernst","id":289412,"avatar_url":"https://avatars.githubusercontent.com/u/289412?v=3","gravatar_id":"","url":"https://api.github.com/users/rjernst","html_url":"https://github.com/rjernst","followers_url":"https://api.github.com/users/rjernst/followers","following_url":"https://api.github.com/users/rjernst/following{/other_user}","gists_url":"https://api.github.com/users/rjernst/gists{/gist_id}","starred_url":"https://api.github.com/users/rjernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjernst/subscriptions","organizations_url":"https://api.github.com/users/rjernst/orgs","repos_url":"https://api.github.com/users/rjernst/repos","events_url":"https://api.github.com/users/rjernst/events{/privacy}","received_events_url":"https://api.github.com/users/rjernst/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2014-11-27T17:00:20Z","updated_at":"2015-02-10T21:07:04Z","closed_at":null,"body":"Today, a new field can be added to the local mapping of two shards simultaneously. If the detected field type is different, then each shard can end up with a different field type.  These shards then send their new mapping to the master, but only of the mappings will win.\r\n\r\nThis can result in incorrect results and even data loss, eg: one shard thinks that the field is a string, and the other shard (and the master) thinks that it is a number.  In this case, sorting and aggregations will be wrong (#8485).  Then, when the string-shard is allocated to a new node, that node will receive the \"number\" mapping from the master.  Replaying the transaction log can cause shard failures (eg #8684).  Or new numeric doc values are written but, when we try to merge segments, it fails with a doc values exception (https://github.com/elasticsearch/elasticsearch/issues/8009).\r\n\r\nThe only way to ensure that dynamic fields are the same on all shards is to wait for the master to acknowledge the mapping changes before indexing the document, so:\r\n\r\n* parse the document\r\n* update local mapping\r\n* **if changed, send to master and wait for ack**\r\n* index document\r\n\r\nThis will potentially slow down indexing when many dynamic fields are being added, but it is the only way to automatically protect against data loss due to mapping conflicts.\r\n\r\nShould a user wish to disable waiting for the master (and they are certain that their dynamic mapping rules are good enough to prevent these problems) then we should allow them to opt-out by setting `\"dynamic\": \"unsafe\"`\r\n"},"comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/comments/73783685","html_url":"https://github.com/elasticsearch/elasticsearch/issues/8688#issuecomment-73783685","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/8688","id":73783685,"user":{"login":"bleskes","id":1006375,"avatar_url":"https://avatars.githubusercontent.com/u/1006375?v=3","gravatar_id":"","url":"https://api.github.com/users/bleskes","html_url":"https://github.com/bleskes","followers_url":"https://api.github.com/users/bleskes/followers","following_url":"https://api.github.com/users/bleskes/following{/other_user}","gists_url":"https://api.github.com/users/bleskes/gists{/gist_id}","starred_url":"https://api.github.com/users/bleskes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleskes/subscriptions","organizations_url":"https://api.github.com/users/bleskes/orgs","repos_url":"https://api.github.com/users/bleskes/repos","events_url":"https://api.github.com/users/bleskes/events{/privacy}","received_events_url":"https://api.github.com/users/bleskes/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T21:07:04Z","updated_at":"2015-02-10T21:07:04Z","body":"> I was thinking that this shouldn't cause ES to fail recovery (as you said).\r\n\r\n@sammcj it maybe unrelated. When you say the recovery failed - did you check using `GET _recovery` to see there were no progress at all? (As opposed to being very slow...)"}}