1
0

delayed.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <<cluster-shard-allocation-settings,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-flush, 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,console]
  31. ------------------------------
  32. PUT _all/_settings
  33. {
  34. "settings": {
  35. "index.unassigned.node_left.delayed_timeout": "5m"
  36. }
  37. }
  38. ------------------------------
  39. // TEST[s/^/PUT test\n/]
  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. In particular, delayed allocation does not come into effect after a full cluster restart.
  50. Also, in case of a master failover situation, elapsed delay time is forgotten
  51. (i.e. reset to the full initial delay).
  52. ==== Cancellation of shard relocation
  53. If delayed allocation times out, the master assigns the missing shards to
  54. another node which will start recovery. If the missing node rejoins the
  55. cluster, and its shards still have the same sync-id as the primary, shard
  56. relocation will be cancelled and the synced shard will be used for recovery
  57. instead.
  58. For this reason, the default `timeout` is set to just one minute: even if shard
  59. relocation begins, cancelling recovery in favour of the synced shard is cheap.
  60. ==== Monitoring delayed unassigned shards
  61. The number of shards whose allocation has been delayed by this timeout setting
  62. can be viewed with the <<cluster-health,cluster health API>>:
  63. [source,console]
  64. ------------------------------
  65. GET _cluster/health <1>
  66. ------------------------------
  67. <1> This request will return a `delayed_unassigned_shards` value.
  68. ==== Removing a node permanently
  69. If a node is not going to return and you would like Elasticsearch to allocate
  70. the missing shards immediately, just update the timeout to zero:
  71. [source,console]
  72. ------------------------------
  73. PUT _all/_settings
  74. {
  75. "settings": {
  76. "index.unassigned.node_left.delayed_timeout": "0"
  77. }
  78. }
  79. ------------------------------
  80. // TEST[s/^/PUT test\n/]
  81. You can reset the timeout as soon as the missing shards have started to recover.