translog.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. [[index-modules-translog]]
  2. == Translog
  3. Changes to Lucene are only persisted to disk during a Lucene commit,
  4. which is a relatively heavy operation and so cannot be performed after every
  5. index or delete operation. Changes that happen after one commit and before another
  6. will be lost in the event of process exit or HW failure.
  7. To prevent this data loss, each shard has a _transaction log_ or write ahead
  8. log associated with it. Any index or delete operation is written to the
  9. translog after being processed by the internal Lucene index.
  10. In the event of a crash, recent transactions can be replayed from the
  11. transaction log when the shard recovers.
  12. An Elasticsearch flush is the process of performing a Lucene commit and
  13. starting a new translog. It is done automatically in the background in order
  14. to make sure the transaction log doesn't grow too large, which would make
  15. replaying its operations take a considerable amount of time during recovery.
  16. It is also exposed through an API, though its rarely needed to be performed
  17. manually.
  18. [float]
  19. === Flush settings
  20. The following <<indices-update-settings,dynamically updatable>> settings
  21. control how often the in-memory buffer is flushed to disk:
  22. `index.translog.flush_threshold_size`::
  23. Once the translog hits this size, a flush will happen. Defaults to `512mb`.
  24. `index.translog.flush_threshold_ops`::
  25. After how many operations to flush. Defaults to `unlimited`.
  26. `index.translog.flush_threshold_period`::
  27. How long to wait before triggering a flush regardless of translog size. Defaults to `30m`.
  28. `index.translog.interval`::
  29. How often to check if a flush is needed, randomized between the interval value
  30. and 2x the interval value. Defaults to `5s`.
  31. [float]
  32. === Translog settings
  33. The data in the transaction log is only persisted to disk when the translog is
  34. ++fsync++ed and committed. In the event of hardware failure, any data written
  35. since the previous translog commit will be lost.
  36. By default, Elasticsearch ++fsync++s and commits the translog every 5 seconds
  37. and at the end of every <<docs-index_,index>>, <<docs-delete,delete>>,
  38. <<docs-update,update>>, or <<docs-bulk,bulk>> request. In fact, Elasticsearch
  39. will only report success of an index, delete, update, or bulk request to the
  40. client after the transaction log has been successfully ++fsync++ed and committed
  41. on the primary and on every allocated replica.
  42. The following <<indices-update-settings,dynamically updatable>> per-index settings
  43. control the behaviour of the transaction log:
  44. `index.translog.sync_interval`::
  45. How often the translog is ++fsync++ed to disk and committed, regardless of
  46. write operations. Defaults to `5s`.
  47. `index.translog.durability`::
  48. +
  49. --
  50. Whether or not to `fsync` and commit the translog after every index, delete,
  51. update, or bulk request. This setting accepts the following parameters:
  52. `request`::
  53. (default) `fsync` and commit after every request. In the event
  54. of hardware failure, all acknowledged writes will already have been
  55. commited to disk.
  56. `async`::
  57. `fsync` and commit in the background every `sync_interval`. In
  58. the event of hardware failure, all acknowledged writes since the last
  59. automatic commit will be discarded.
  60. --
  61. `index.translog.fs.type`::
  62. +
  63. --
  64. Whether to buffer writes to the transaction log in memory or not. This
  65. setting accepts the following parameters:
  66. `buffered`::
  67. (default) Translog writes first go to a 64kB buffer in memory,
  68. and are only written to the disk when the buffer is full, or when an
  69. `fsync` is triggered by a write request or the `sync_interval`.
  70. `simple`::
  71. Translog writes are written to the file system immediately, without
  72. buffering. However, these writes will only be persisted to disk when an
  73. `fsync` and commit is triggered by a write request or the `sync_interval`.
  74. --