translog.asciidoc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. Lucene commits are too expensive to perform on every individual change, so each
  9. shard copy also writes operations into its _transaction log_ known as the
  10. _translog_. 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 operations that have been acknowledged but not
  13. yet included in the last Lucene commit are instead recovered from the translog
  14. when the shard recovers.
  15. An {es} <<indices-flush,flush>> is the process of performing a Lucene commit and
  16. starting a new translog generation. Flushes are performed automatically in the
  17. background in order to make sure the translog does not grow too large, which
  18. would make replaying its operations take a considerable amount of time during
  19. recovery. The ability to perform a flush manually is also exposed through an
  20. API, although this is rarely needed.
  21. [discrete]
  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
  28. Elasticsearch will only report success of an index, delete, update, or bulk
  29. request to the client after the translog has been successfully ++fsync++ed and
  30. committed on the primary and on every allocated replica. If
  31. `index.translog.durability` is set to `async` then Elasticsearch ++fsync++s and
  32. commits the translog only every `index.translog.sync_interval` which means that
  33. any operations that were performed just before a crash may be lost when the node
  34. recovers.
  35. The following <<indices-update-settings,dynamically updatable>> per-index
  36. settings control the behaviour of the translog:
  37. `index.translog.sync_interval`::
  38. How often the translog is ++fsync++ed to disk and committed, regardless of
  39. write operations. Defaults to `5s`. Values less than `100ms` are not allowed.
  40. `index.translog.durability`::
  41. +
  42. --
  43. Whether or not to `fsync` and commit the translog after every index, delete,
  44. update, or bulk request. This setting accepts the following parameters:
  45. `request`::
  46. (default) `fsync` and commit after every request. In the event of hardware
  47. failure, all acknowledged writes will already have been committed to disk.
  48. `async`::
  49. `fsync` and commit in the background every `sync_interval`. In
  50. the event of a failure, all acknowledged writes since the last
  51. automatic commit will be discarded.
  52. --
  53. `index.translog.flush_threshold_size`::
  54. The translog stores all operations that are not yet safely persisted in Lucene
  55. (i.e., are not part of a Lucene commit point). Although these operations are
  56. available for reads, they will need to be replayed if the shard was stopped
  57. and had to be recovered. This setting controls the maximum total size of these
  58. operations, to prevent recoveries from taking too long. Once the maximum size
  59. has been reached a flush will happen, generating a new Lucene commit point.
  60. Defaults to `512mb`.