error-handling.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[index-lifecycle-error-handling]]
  4. == Index lifecycle error handling
  5. During Index Lifecycle Management's execution of the policy for an index, it's
  6. possible for a step to encounter an error during its execution. When this
  7. happens, ILM will move the management state into an "error" step. This halts
  8. further execution of the policy and gives an administrator the chance to address
  9. any issues with the policy, index, or cluster.
  10. An example will be helpful in illustrating this, imagine the following policy
  11. has been created by a user:
  12. [source,js]
  13. --------------------------------------------------
  14. PUT _ilm/policy/shrink-the-index
  15. {
  16. "policy": {
  17. "phases": {
  18. "warm": {
  19. "min_age": "5d",
  20. "actions": {
  21. "shrink": {
  22. "number_of_shards": 4
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }
  29. --------------------------------------------------
  30. // CONSOLE
  31. // TEST
  32. This policy waits until the index is at least 5 days old, and then shrinks
  33. the index to 4 shards.
  34. Now imagine that a user creates a new index "myindex" with two primary shards,
  35. telling it to use the policy they have created:
  36. [source,js]
  37. --------------------------------------------------
  38. PUT /myindex
  39. {
  40. "settings": {
  41. "index.number_of_shards": 2,
  42. "index.lifecycle.name": "shrink-the-index"
  43. }
  44. }
  45. --------------------------------------------------
  46. // CONSOLE
  47. // TEST[continued]
  48. After five days have passed, ILM will attempt to shrink this index from 2
  49. shards to 4, which is invalid since the shrink action cannot increase the
  50. number of shards. When this occurs, ILM will move this
  51. index to the "error" step. Once an index is in this step, information about the
  52. reason for the error can be retrieved from the <<ilm-explain-lifecycle,ILM Explain API>>:
  53. [source,js]
  54. --------------------------------------------------
  55. GET /myindex/_ilm/explain
  56. --------------------------------------------------
  57. // CONSOLE
  58. // TEST[continued]
  59. Which returns the following information:
  60. [source,js]
  61. --------------------------------------------------
  62. {
  63. "indices" : {
  64. "myindex" : {
  65. "index" : "myindex",
  66. "managed" : true, <1>
  67. "policy" : "shrink-the-index", <2>
  68. "lifecycle_date_millis" : 1541717265865,
  69. "age": "5.1d", <3>
  70. "phase" : "warm", <4>
  71. "phase_time_millis" : 1541717272601,
  72. "action" : "shrink", <5>
  73. "action_time_millis" : 1541717272601,
  74. "step" : "ERROR", <6>
  75. "step_time_millis" : 1541717272688,
  76. "failed_step" : "shrink", <7>
  77. "step_info" : {
  78. "type" : "illegal_argument_exception", <8>
  79. "reason" : "the number of target shards [4] must be less that the number of source shards [2]" <9>
  80. },
  81. "phase_execution" : {
  82. "policy" : "shrink-the-index",
  83. "phase_definition" : { <10>
  84. "min_age" : "5d",
  85. "actions" : {
  86. "shrink" : {
  87. "number_of_shards" : 4
  88. }
  89. }
  90. },
  91. "version" : 1,
  92. "modified_date_in_millis" : 1541717264230
  93. }
  94. }
  95. }
  96. }
  97. --------------------------------------------------
  98. // CONSOLE
  99. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  100. <1> this index is managed by ILM
  101. <2> the policy in question, in this case, "shrink-the-index"
  102. <3> the current age for the index
  103. <4> what phase the index is currently in
  104. <5> what action the index is currently on
  105. <6> what step the index is currently on, in this case, because there is an error, the index is in the "ERROR" step
  106. <7> the name of the step that failed to execute, in this case "shrink"
  107. <8> the error class that occurred during this step
  108. <9> the error message that occurred during the execution failure
  109. <10> the definition of the phase (in this case, the "warm" phase) that the index is currently on
  110. The index here has been moved to the error step because the shrink definition in
  111. the policy is using an incorrect number of shards. So rectifying that in the
  112. policy entails updating the existing policy to use one instead of four for
  113. the targeted number of shards.
  114. [source,js]
  115. --------------------------------------------------
  116. PUT _ilm/policy/shrink-the-index
  117. {
  118. "policy": {
  119. "phases": {
  120. "warm": {
  121. "min_age": "5d",
  122. "actions": {
  123. "shrink": {
  124. "number_of_shards": 1
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. --------------------------------------------------
  132. // CONSOLE
  133. // TEST[continued]
  134. [float]
  135. === Retrying failed index lifecycle management steps
  136. Once the underlying issue that caused an index to move to the error step has
  137. been corrected, index lifecycle management must be told to retry the step to see
  138. if it can progress further. This is accomplished by invoking the retry API
  139. [source,js]
  140. --------------------------------------------------
  141. POST /myindex/_ilm/retry
  142. --------------------------------------------------
  143. // CONSOLE
  144. // TEST[skip:we can't be sure the index is ready to be retried at this point]
  145. Once this has been issue, index lifecycle management will asynchronously pick up
  146. on the step that is in a failed state, attempting to re-run it. The
  147. <<ilm-explain-lifecycle,ILM Explain API>> can again be used to monitor the status of
  148. re-running the step.