translog.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. [float]
  27. === Translog settings
  28. The data in the transaction log is only persisted to disk when the translog is
  29. ++fsync++ed and committed. In the event of hardware failure, any data written
  30. since the previous translog commit will be lost.
  31. By default, Elasticsearch ++fsync++s and commits the translog every 5 seconds
  32. and at the end of every <<docs-index_,index>>, <<docs-delete,delete>>,
  33. <<docs-update,update>>, or <<docs-bulk,bulk>> request. In fact, Elasticsearch
  34. will only report success of an index, delete, update, or bulk request to the
  35. client after the transaction log has been successfully ++fsync++ed and committed
  36. on the primary and on every allocated replica.
  37. The following <<indices-update-settings,dynamically updatable>> per-index settings
  38. control the behaviour of the transaction log:
  39. `index.translog.sync_interval`::
  40. How often the translog is ++fsync++ed to disk and committed, regardless of
  41. write operations. Defaults to `5s`.
  42. `index.translog.durability`::
  43. +
  44. --
  45. Whether or not to `fsync` and commit the translog after every index, delete,
  46. update, or bulk request. This setting accepts the following parameters:
  47. `request`::
  48. (default) `fsync` and commit after every request. In the event
  49. of hardware failure, all acknowledged writes will already have been
  50. commited to disk.
  51. `async`::
  52. `fsync` and commit in the background every `sync_interval`. In
  53. the event of hardware failure, all acknowledged writes since the last
  54. automatic commit will be discarded.
  55. --
  56. `index.translog.fs.type`::
  57. +
  58. --
  59. Whether to buffer writes to the transaction log in memory or not. This
  60. setting accepts the following parameters:
  61. `buffered`::
  62. (default) Translog writes first go to a 64kB buffer in memory,
  63. and are only written to the disk when the buffer is full, or when an
  64. `fsync` is triggered by a write request or the `sync_interval`.
  65. `simple`::
  66. Translog writes are written to the file system immediately, without
  67. buffering. However, these writes will only be persisted to disk when an
  68. `fsync` and commit is triggered by a write request or the `sync_interval`.
  69. --