recovery.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. [[indices-recovery]]
  2. === Index recovery API
  3. ++++
  4. <titleabbrev>Index recovery</titleabbrev>
  5. ++++
  6. Returns information about ongoing and completed shard recoveries.
  7. [source,console]
  8. ----
  9. GET /twitter/_recovery
  10. ----
  11. // TEST[setup:twitter]
  12. [[index-recovery-api-request]]
  13. ==== {api-request-title}
  14. `GET /<index>/_recovery`
  15. `GET /_recovery`
  16. [[index-recovery-api-desc]]
  17. ==== {api-description-title}
  18. Use the index recovery API
  19. to get information about ongoing and completed shard recoveries.
  20. // tag::shard-recovery-desc[]
  21. Shard recovery is the process
  22. of syncing a replica shard from a primary shard.
  23. Upon completion,
  24. the replica shard is available for search.
  25. include::{docdir}/glossary.asciidoc[tag=recovery-triggers]
  26. // end::shard-recovery-desc[]
  27. [[index-recovery-api-path-params]]
  28. ==== {api-path-parms-title}
  29. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  30. +
  31. Use a value of `_all` to retrieve information for all indices in the cluster.
  32. [[index-recovery-api-query-params]]
  33. ==== {api-query-parms-title}
  34. include::{docdir}/rest-api/common-parms.asciidoc[tag=active-only]
  35. include::{docdir}/rest-api/common-parms.asciidoc[tag=detailed]
  36. include::{docdir}/rest-api/common-parms.asciidoc[tag=index-query-parm]
  37. [[index-recovery-api-response-body]]
  38. ==== {api-response-body-title}
  39. `id`::
  40. (Integer)
  41. ID of the shard.
  42. `type`::
  43. +
  44. --
  45. (String)
  46. Recovery type.
  47. Returned values include:
  48. `STORE`::
  49. The recovery is related to
  50. a node startup or failure.
  51. This type of recovery is called a local store recovery.
  52. `SNAPSHOT`::
  53. The recovery is related to
  54. a <<restore-snapshot,snapshot restoration>>.
  55. `REPLICA`::
  56. The recovery is related to
  57. a <<glossary-replica-shard,primary shard replication>>.
  58. `RELOCATING`::
  59. The recovery is related to
  60. the relocation of a shard
  61. to a different node in the same cluster.
  62. --
  63. `STAGE`::
  64. +
  65. --
  66. (String)
  67. Recovery stage.
  68. Returned values include:
  69. `DONE`::
  70. Complete.
  71. `FINALIZE`::
  72. Cleanup.
  73. `INDEX`::
  74. Reading index metadata and copying bytes from source to destination.
  75. `INIT`::
  76. Recovery has not started.
  77. `START`::
  78. Starting the recovery process; opening the index for use.
  79. `TRANSLOG`::
  80. Replaying transaction log .
  81. --
  82. `primary`::
  83. (Boolean)
  84. If `true`,
  85. the shard is a primary shard.
  86. `start_time`::
  87. (String)
  88. Timestamp of recovery start.
  89. `stop_time`::
  90. (String)
  91. Timestamp of recovery finish.
  92. `total_time_in_millis`::
  93. (String)
  94. Total time to recover shard in milliseconds.
  95. `source`::
  96. +
  97. --
  98. (Object)
  99. Recovery source.
  100. This can include:
  101. * A repository description if recovery is from a snapshot
  102. * A description of source node
  103. --
  104. `target`::
  105. (Object)
  106. Destination node.
  107. `index`::
  108. (Object)
  109. Statistics about physical index recovery.
  110. `translog`::
  111. (Object)
  112. Statistics about translog recovery.
  113. `start`::
  114. (Object)
  115. Statistics about time to open and start the index.
  116. [[index-recovery-api-example]]
  117. ==== {api-examples-title}
  118. [[index-recovery-api-multi-ex]]
  119. ===== Get recovery information for several indices
  120. [source,console]
  121. --------------------------------------------------
  122. GET index1,index2/_recovery?human
  123. --------------------------------------------------
  124. // TEST[s/^/PUT index1\nPUT index2\n/]
  125. [[index-recovery-api-all-ex]]
  126. ===== Get segment information for all indices
  127. //////////////////////////
  128. Here we create a repository and snapshot index1 in
  129. order to restore it right after and prints out the
  130. index recovery result.
  131. [source,console]
  132. --------------------------------------------------
  133. # create the index
  134. PUT index1
  135. {"settings": {"index.number_of_shards": 1}}
  136. # create the repository
  137. PUT /_snapshot/my_repository
  138. {"type": "fs","settings": {"location": "recovery_asciidoc" }}
  139. # snapshot the index
  140. PUT /_snapshot/my_repository/snap_1?wait_for_completion=true
  141. {"indices": "index1"}
  142. # delete the index
  143. DELETE index1
  144. # and restore the snapshot
  145. POST /_snapshot/my_repository/snap_1/_restore?wait_for_completion=true
  146. --------------------------------------------------
  147. [source,console-result]
  148. --------------------------------------------------
  149. {
  150. "snapshot": {
  151. "snapshot": "snap_1",
  152. "indices": [
  153. "index1"
  154. ],
  155. "shards": {
  156. "total": 1,
  157. "failed": 0,
  158. "successful": 1
  159. }
  160. }
  161. }
  162. --------------------------------------------------
  163. //////////////////////////
  164. [source,console]
  165. --------------------------------------------------
  166. GET /_recovery?human
  167. --------------------------------------------------
  168. // TEST[continued]
  169. The API returns the following response:
  170. [source,console-result]
  171. --------------------------------------------------
  172. {
  173. "index1" : {
  174. "shards" : [ {
  175. "id" : 0,
  176. "type" : "SNAPSHOT",
  177. "stage" : "INDEX",
  178. "primary" : true,
  179. "start_time" : "2014-02-24T12:15:59.716",
  180. "start_time_in_millis": 1393244159716,
  181. "stop_time" : "0s",
  182. "stop_time_in_millis" : 0,
  183. "total_time" : "2.9m",
  184. "total_time_in_millis" : 175576,
  185. "source" : {
  186. "repository" : "my_repository",
  187. "snapshot" : "my_snapshot",
  188. "index" : "index1",
  189. "version" : "{version}",
  190. "restoreUUID": "PDh1ZAOaRbiGIVtCvZOMww"
  191. },
  192. "target" : {
  193. "id" : "ryqJ5lO5S4-lSFbGntkEkg",
  194. "host" : "my.fqdn",
  195. "transport_address" : "my.fqdn",
  196. "ip" : "10.0.1.7",
  197. "name" : "my_es_node"
  198. },
  199. "index" : {
  200. "size" : {
  201. "total" : "75.4mb",
  202. "total_in_bytes" : 79063092,
  203. "reused" : "0b",
  204. "reused_in_bytes" : 0,
  205. "recovered" : "65.7mb",
  206. "recovered_in_bytes" : 68891939,
  207. "percent" : "87.1%"
  208. },
  209. "files" : {
  210. "total" : 73,
  211. "reused" : 0,
  212. "recovered" : 69,
  213. "percent" : "94.5%"
  214. },
  215. "total_time" : "0s",
  216. "total_time_in_millis" : 0,
  217. "source_throttle_time" : "0s",
  218. "source_throttle_time_in_millis" : 0,
  219. "target_throttle_time" : "0s",
  220. "target_throttle_time_in_millis" : 0
  221. },
  222. "translog" : {
  223. "recovered" : 0,
  224. "total" : 0,
  225. "percent" : "100.0%",
  226. "total_on_start" : 0,
  227. "total_time" : "0s",
  228. "total_time_in_millis" : 0,
  229. },
  230. "verify_index" : {
  231. "check_index_time" : "0s",
  232. "check_index_time_in_millis" : 0,
  233. "total_time" : "0s",
  234. "total_time_in_millis" : 0
  235. }
  236. } ]
  237. }
  238. }
  239. --------------------------------------------------
  240. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  241. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  242. ////
  243. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  244. because we don't really care about the field values but we want to check the fields names.
  245. ////
  246. This response includes information
  247. about a single index recovering a single shard.
  248. The source of the recovery is a snapshot repository
  249. and the target of the recovery is the `my_es_node` node.
  250. The response also includes the number
  251. and percentage of files and bytes recovered.
  252. [[index-recovery-api-detailed-ex]]
  253. ===== Get detailed recovery information
  254. To get a list of physical files in recovery,
  255. set the `detailed` query parameter to `true`.
  256. [source,console]
  257. --------------------------------------------------
  258. GET _recovery?human&detailed=true
  259. --------------------------------------------------
  260. // TEST[s/^/PUT index1\n{"settings": {"index.number_of_shards": 1}}\n/]
  261. The API returns the following response:
  262. [source,console-result]
  263. --------------------------------------------------
  264. {
  265. "index1" : {
  266. "shards" : [ {
  267. "id" : 0,
  268. "type" : "STORE",
  269. "stage" : "DONE",
  270. "primary" : true,
  271. "start_time" : "2014-02-24T12:38:06.349",
  272. "start_time_in_millis" : "1393245486349",
  273. "stop_time" : "2014-02-24T12:38:08.464",
  274. "stop_time_in_millis" : "1393245488464",
  275. "total_time" : "2.1s",
  276. "total_time_in_millis" : 2115,
  277. "source" : {
  278. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  279. "host" : "my.fqdn",
  280. "transport_address" : "my.fqdn",
  281. "ip" : "10.0.1.7",
  282. "name" : "my_es_node"
  283. },
  284. "target" : {
  285. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  286. "host" : "my.fqdn",
  287. "transport_address" : "my.fqdn",
  288. "ip" : "10.0.1.7",
  289. "name" : "my_es_node"
  290. },
  291. "index" : {
  292. "size" : {
  293. "total" : "24.7mb",
  294. "total_in_bytes" : 26001617,
  295. "reused" : "24.7mb",
  296. "reused_in_bytes" : 26001617,
  297. "recovered" : "0b",
  298. "recovered_in_bytes" : 0,
  299. "percent" : "100.0%"
  300. },
  301. "files" : {
  302. "total" : 26,
  303. "reused" : 26,
  304. "recovered" : 0,
  305. "percent" : "100.0%",
  306. "details" : [ {
  307. "name" : "segments.gen",
  308. "length" : 20,
  309. "recovered" : 20
  310. }, {
  311. "name" : "_0.cfs",
  312. "length" : 135306,
  313. "recovered" : 135306
  314. }, {
  315. "name" : "segments_2",
  316. "length" : 251,
  317. "recovered" : 251
  318. }
  319. ]
  320. },
  321. "total_time" : "2ms",
  322. "total_time_in_millis" : 2,
  323. "source_throttle_time" : "0s",
  324. "source_throttle_time_in_millis" : 0,
  325. "target_throttle_time" : "0s",
  326. "target_throttle_time_in_millis" : 0
  327. },
  328. "translog" : {
  329. "recovered" : 71,
  330. "total" : 0,
  331. "percent" : "100.0%",
  332. "total_on_start" : 0,
  333. "total_time" : "2.0s",
  334. "total_time_in_millis" : 2025
  335. },
  336. "verify_index" : {
  337. "check_index_time" : 0,
  338. "check_index_time_in_millis" : 0,
  339. "total_time" : "88ms",
  340. "total_time_in_millis" : 88
  341. }
  342. } ]
  343. }
  344. }
  345. --------------------------------------------------
  346. // TESTRESPONSE[s/"source" : \{[^}]*\}/"source" : $body.$_path/]
  347. // TESTRESPONSE[s/"details" : \[[^\]]*\]/"details" : $body.$_path/]
  348. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  349. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  350. ////
  351. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  352. because we don't really care about the field values but we want to check the fields names.
  353. It also removes the "details" part which is important in this doc but really hard to test.
  354. ////
  355. The response includes a listing
  356. of any physical files recovered
  357. and their sizes.
  358. The response also includes timings in milliseconds
  359. of the various stages of recovery:
  360. * Index retrieval
  361. * Translog replay
  362. * Index start time
  363. This response indicates the recovery is `done`.
  364. All recoveries,
  365. whether ongoing or complete,
  366. are kept in the cluster state
  367. and may be reported on at any time.
  368. To only return information about ongoing recoveries,
  369. set the `active_only` query parameter to `true`.