{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/14319","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14319/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14319/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14319/events","html_url":"https://github.com/elastic/elasticsearch/issues/14319","id":113691352,"number":14319,"title":"Shards out of sync when setting  refresh_interval & number_of_replicas at the same time","user":{"login":"msimos","id":11743255,"avatar_url":"https://avatars.githubusercontent.com/u/11743255?v=3","gravatar_id":"","url":"https://api.github.com/users/msimos","html_url":"https://github.com/msimos","followers_url":"https://api.github.com/users/msimos/followers","following_url":"https://api.github.com/users/msimos/following{/other_user}","gists_url":"https://api.github.com/users/msimos/gists{/gist_id}","starred_url":"https://api.github.com/users/msimos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msimos/subscriptions","organizations_url":"https://api.github.com/users/msimos/orgs","repos_url":"https://api.github.com/users/msimos/repos","events_url":"https://api.github.com/users/msimos/events{/privacy}","received_events_url":"https://api.github.com/users/msimos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Core","name":":Core","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/bug","name":"bug","color":"9e2c2c"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/v1.7.3","name":"v1.7.3","color":"dddddd"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-10-27T21:17:45Z","updated_at":"2015-11-02T21:00:56Z","closed_at":null,"body":"If you create an index number_of_replicas to 0 and refresh_interval to -1 (using one API call) & add some documents. Then set number_number_of_replicas to 1 and refresh_interval to \"1s\" and add some more documents. The primary and replicas are out of sync, it looks like the replica doesn't have the new documents. See this gist for a repro:\r\n\r\nhttps://gist.github.com/msimos/869292265208852fbee4\r\n\r\nIf you run the match_all query multiple times you'll see the different documents returned. If you use preference=_primary then all documents are returned. If the query hits the replica, then only the first documents are returned when replicas were set to 0. Also using _cat/shards you can see the size difference between the shards.\r\n\r\nIt seems you can workaround this by doing sending this in two separate calls:\r\n\r\n```\r\nPUT /index/_settings\r\n{\r\n  \"number_of_replicas\": 1\r\n}\r\n\r\nPUT /index/_settings\r\n{\r\n  \"refresh_interval\": \"1s\"\r\n}\r\n```\r\nAlso seems the ordering matters, that \"number_of_replicas\": 1 is set before \"refresh_interval\": \"1s\". This was on Elasticsearch 1.7.2.\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/153155163","html_url":"https://github.com/elastic/elasticsearch/issues/14319#issuecomment-153155163","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14319","id":153155163,"user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T21:00:56Z","updated_at":"2015-11-02T21:00:56Z","body":"> @s1monw master doesn't have the bug either ... I'm not sure why.\r\n\r\n@mikemccand in master I trashed this Provider @bleskes is talking about entirely. New shards are guaranteed to see the latest settings."}}