error-handling.asciidoc 5.2 KB

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