error-handling.asciidoc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. "phase" : "warm", <3>
  70. "phase_time_millis" : 1541717272601,
  71. "action" : "shrink", <4>
  72. "action_time_millis" : 1541717272601,
  73. "step" : "ERROR", <5>
  74. "step_time_millis" : 1541717272688,
  75. "failed_step" : "shrink", <6>
  76. "step_info" : {
  77. "type" : "illegal_argument_exception", <7>
  78. "reason" : "the number of target shards [4] must be less that the number of source shards [2]" <8>
  79. },
  80. "phase_execution" : {
  81. "policy" : "shrink-the-index",
  82. "phase_definition" : { <9>
  83. "min_age" : "5d",
  84. "actions" : {
  85. "shrink" : {
  86. "number_of_shards" : 4
  87. }
  88. }
  89. },
  90. "version" : 1,
  91. "modified_date_in_millis" : 1541717264230
  92. }
  93. }
  94. }
  95. }
  96. --------------------------------------------------
  97. // CONSOLE
  98. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  99. <1> this index is managed by ILM
  100. <2> the policy in question, in this case, "shrink-the-index"
  101. <3> what phase the index is currently in
  102. <4> what action the index is currently on
  103. <5> what step the index is currently on, in this case, because there is an error, the index is in the "ERROR" step
  104. <6> the name of the step that failed to execute, in this case "shrink"
  105. <7> the error class that occurred during this step
  106. <8> the error message that occurred during the execution failure
  107. <9> the definition of the phase (in this case, the "warm" phase) that the index is currently on
  108. The index here has been moved to the error step because the shrink definition in
  109. the policy is using an incorrect number of shards. So rectifying that in the
  110. policy entails updating the existing policy to use one instead of four for
  111. the targeted number of shards.
  112. [source,js]
  113. --------------------------------------------------
  114. PUT _ilm/policy/shrink-the-index
  115. {
  116. "policy": {
  117. "phases": {
  118. "warm": {
  119. "min_age": "5d",
  120. "actions": {
  121. "shrink": {
  122. "number_of_shards": 1
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. --------------------------------------------------
  130. // CONSOLE
  131. // TEST[continued]
  132. [float]
  133. === Retrying failed index lifecycle management steps
  134. Once the underlying issue that caused an index to move to the error step has
  135. been corrected, index lifecycle management must be told to retry the step to see
  136. if it can progress further. This is accomplished by invoking the retry API
  137. [source,js]
  138. --------------------------------------------------
  139. POST /myindex/_ilm/retry
  140. --------------------------------------------------
  141. // CONSOLE
  142. // TEST[skip:we can't be sure the index is ready to be retried at this point]
  143. Once this has been issue, index lifecycle management will asynchronously pick up
  144. on the step that is in a failed state, attempting to re-run it. The
  145. <<ilm-explain-lifecycle,ILM Explain API>> can again be used to monitor the status of
  146. re-running the step.