translog.asciidoc 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 a hardware failure or an operating
  25. system crash or a JVM crash or a shard failure, any data written since the
  26. previous translog commit will be lost.
  27. By default, `index.translog.durability` is set to `request` meaning that Elasticsearch will only report success of an index, delete,
  28. update, or bulk request to the client after the translog has been successfully
  29. ++fsync++ed and committed on the primary and on every allocated replica. If
  30. `index.translog.durability` is set to `async` then Elasticsearch ++fsync++s
  31. and commits the translog every `index.translog.sync_interval` (defaults to 5 seconds).
  32. The following <<indices-update-settings,dynamically updatable>> per-index
  33. settings control the behaviour of the translog:
  34. `index.translog.sync_interval`::
  35. How often the translog is ++fsync++ed to disk and committed, regardless of
  36. write operations. Defaults to `5s`. Values less than `100ms` are not allowed.
  37. `index.translog.durability`::
  38. +
  39. --
  40. Whether or not to `fsync` and commit the translog after every index, delete,
  41. update, or bulk request. This setting accepts the following parameters:
  42. `request`::
  43. (default) `fsync` and commit after every request. In the event
  44. of hardware failure, all acknowledged writes will already have been
  45. committed to disk.
  46. `async`::
  47. `fsync` and commit in the background every `sync_interval`. In
  48. the event of a failure, all acknowledged writes since the last
  49. automatic commit will be discarded.
  50. --
  51. `index.translog.flush_threshold_size`::
  52. The translog stores all operations that are not yet safely persisted in Lucene
  53. (i.e., are not part of a Lucene commit point). Although these operations are
  54. available for reads, they will need to be reindexed if the shard was to
  55. shutdown and has to be recovered. This settings controls the maximum total size
  56. of these operations, to prevent recoveries from taking too long. Once the
  57. maximum size has been reached a flush will happen, generating a new Lucene
  58. commit point. Defaults to `512mb`.
  59. `index.translog.retention.size`::
  60. When soft deletes is disabled (enabled by default in 7.0 or later),
  61. `index.translog.retention.size` controls the total size of translog files to keep.
  62. Keeping more translog files increases the chance of performing an operation based
  63. sync when recovering replicas. If the translog files are not sufficient,
  64. replica recovery will fall back to a file based sync. Defaults to `512mb`
  65. Both `index.translog.retention.size` and `index.translog.retention.age` should not
  66. be specified unless soft deletes is disabled as they will be ignored.
  67. `index.translog.retention.age`::
  68. When soft deletes is disabled (enabled by default in 7.0 or later),
  69. `index.translog.retention.age` controls the maximum duration for which translog
  70. files to keep. Keeping more translog files increases the chance of performing an
  71. operation based sync when recovering replicas. If the translog files are not sufficient,
  72. replica recovery will fall back to a file based sync. Defaults to `12h`
  73. Both `index.translog.retention.size` and `index.translog.retention.age` should not
  74. be specified unless soft deletes is disabled as they will be ignored.