delayed.asciidoc 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. [[delayed-allocation]]
  2. === Delaying allocation when a node leaves
  3. When a node leaves the cluster for whatever reason, intentional or otherwise,
  4. the master reacts by:
  5. * Promoting a replica shard to primary to replace any primaries that were on the node.
  6. * Allocating replica shards to replace the missing replicas (assuming there are enough nodes).
  7. * Rebalancing shards evenly across the remaining nodes.
  8. These actions are intended to protect the cluster against data loss by
  9. ensuring that every shard is fully replicated as soon as possible.
  10. Even though we throttle concurrent recoveries both at the
  11. <<recovery,node level>> and at the <<shards-allocation,cluster level>>, this
  12. ``shard-shuffle'' can still put a lot of extra load on the cluster which
  13. may not be necessary if the missing node is likely to return soon. Imagine
  14. this scenario:
  15. * Node 5 loses network connectivity.
  16. * The master promotes a replica shard to primary for each primary that was on Node 5.
  17. * The master allocates new replicas to other nodes in the cluster.
  18. * Each new replica makes an entire copy of the primary shard across the network.
  19. * More shards are moved to different nodes to rebalance the cluster.
  20. * Node 5 returns after a few minutes.
  21. * The master rebalances the cluster by allocating shards to Node 5.
  22. If the master had just waited for a few minutes, then the missing shards could
  23. have been re-allocated to Node 5 with the minimum of network traffic. This
  24. process would be even quicker for idle shards (shards not receiving indexing
  25. requests) which have been automatically <<indices-synced-flush,sync-flushed>>.
  26. The allocation of replica shards which become unassigned because a node has
  27. left can be delayed with the `index.unassigned.node_left.delayed_timeout`
  28. dynamic setting, which defaults to `1m`.
  29. This setting can be updated on a live index (or on all indices):
  30. [source,js]
  31. ------------------------------
  32. PUT /_all/_settings
  33. {
  34. "settings": {
  35. "index.unassigned.node_left.delayed_timeout": "5m"
  36. }
  37. }
  38. ------------------------------
  39. // AUTOSENSE
  40. With delayed allocation enabled, the above scenario changes to look like this:
  41. * Node 5 loses network connectivity.
  42. * The master promotes a replica shard to primary for each primary that was on Node 5.
  43. * The master logs a message that allocation of unassigned shards has been delayed, and for how long.
  44. * The cluster remains yellow because there are unassigned replica shards.
  45. * Node 5 returns after a few minutes, before the `timeout` expires.
  46. * The missing replicas are re-allocated to Node 5 (and sync-flushed shards recover almost immediately).
  47. NOTE: This setting will not affect the promotion of replicas to primaries, nor
  48. will it affect the assignment of replicas that have not been assigned
  49. previously.
  50. ==== Monitoring delayed unassigned shards
  51. The number of shards whose allocation has been delayed by this timeout setting
  52. can be viewed with the <<cluster-health,cluster health API>>:
  53. [source,js]
  54. ------------------------------
  55. GET _cluster/health <1>
  56. ------------------------------
  57. <1> This request will return a `delayed_unassigned_shards` value.
  58. ==== Removing a node permanently
  59. If a node is not going to return and you would like Elasticsearch to allocate
  60. the missing shards immediately, just update the timeout to zero:
  61. [source,js]
  62. ------------------------------
  63. PUT /_all/_settings
  64. {
  65. "settings": {
  66. "index.unassigned.node_left.delayed_timeout": "0"
  67. }
  68. }
  69. ------------------------------
  70. // AUTOSENSE
  71. You can reset the timeout as soon as the missing shards have started to recover.