translog.asciidoc 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. [[index-modules-translog]]
  2. == Translog
  3. Changes to Lucene are only persisted to disk during a Lucene commit, which is a
  4. relatively expensive operation and so cannot be performed after every index or
  5. delete operation. Changes that happen after one commit and before another will
  6. be removed from the index by Lucene in the event of process exit or hardware
  7. failure.
  8. Because Lucene commits are too expensive to perform on every individual change,
  9. each shard copy also has a _transaction log_ known as its _translog_ associated
  10. with it. All index and delete operations are written to the translog after
  11. being processed by the internal Lucene index but before they are acknowledged.
  12. In the event of a crash, recent transactions that have been acknowledged but
  13. not yet included in the last Lucene commit can instead be recovered from the
  14. translog when the shard recovers.
  15. An Elasticsearch flush is the process of performing a Lucene commit and
  16. starting a new translog. Flushes are performed automatically in the background
  17. in order to make sure the translog doesn't grow too large, which would make
  18. replaying its operations take a considerable amount of time during recovery.
  19. The ability to perform a flush manually is also exposed through an API,
  20. although this is rarely needed.
  21. [float]
  22. === Translog settings
  23. The data in the translog is only persisted to disk when the translog is
  24. ++fsync++ed and committed. In the event of hardware failure, any data written
  25. since the previous translog commit will be lost.
  26. By default, Elasticsearch ++fsync++s and commits the translog every 5 seconds
  27. if `index.translog.durability` is set to `async` or if set to `request`
  28. (default) at the end of every <<docs-index_,index>>, <<docs-delete,delete>>,
  29. <<docs-update,update>>, or <<docs-bulk,bulk>> request. More precisely, if set
  30. to `request`, Elasticsearch will only report success of an index, delete,
  31. update, or bulk request to the client after the translog has been successfully
  32. ++fsync++ed and committed on the primary and on every allocated replica.
  33. The following <<indices-update-settings,dynamically updatable>> per-index
  34. settings control the behaviour of the translog:
  35. `index.translog.sync_interval`::
  36. How often the translog is ++fsync++ed to disk and committed, regardless of
  37. write operations. Defaults to `5s`. Values less than `100ms` are not allowed.
  38. `index.translog.durability`::
  39. +
  40. --
  41. Whether or not to `fsync` and commit the translog after every index, delete,
  42. update, or bulk request. This setting accepts the following parameters:
  43. `request`::
  44. (default) `fsync` and commit after every request. In the event
  45. of hardware failure, all acknowledged writes will already have been
  46. committed to disk.
  47. `async`::
  48. `fsync` and commit in the background every `sync_interval`. In
  49. the event of hardware failure, all acknowledged writes since the last
  50. automatic commit will be discarded.
  51. --
  52. `index.translog.flush_threshold_size`::
  53. The translog stores all operations that are not yet safely persisted in Lucene
  54. (i.e., are not part of a Lucene commit point). Although these operations are
  55. available for reads, they will need to be reindexed if the shard was to
  56. shutdown and has to be recovered. This settings controls the maximum total size
  57. of these operations, to prevent recoveries from taking too long. Once the
  58. maximum size has been reached a flush will happen, generating a new Lucene
  59. commit point. Defaults to `512mb`.
  60. `index.translog.retention.size`::
  61. The total size of translog files to keep. Keeping more translog files increases
  62. the chance of performing an operation based sync when recovering replicas. If
  63. the translog files are not sufficient, replica recovery will fall back to a
  64. file based sync. Defaults to `512mb`
  65. `index.translog.retention.age`::
  66. The maximum duration for which translog files will be kept. Defaults to `12h`.