Skip to content

Commit 2255fd0

Browse files
committed
persistence: update checkpoint daemon section
1 parent 27c688a commit 2255fd0

File tree

3 files changed

+91
-78
lines changed

3 files changed

+91
-78
lines changed

doc/concepts/configuration/configuration_persistence.rst

Lines changed: 79 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Persistence
55

66
To ensure data persistence, Tarantool provides the abilities to:
77

8-
* record each data change request into a :ref:`write-ahead log <internals-wal>` (WAL) file (``.xlog`` files)
9-
* take :ref:`snapshots <internals-snapshot>` that contain on-disk copy of the entire data set for a given moment (``.snap`` files)
8+
* Record each data change request into a :ref:`write-ahead log <internals-wal>` (WAL) file (``.xlog`` files).
9+
* Take :ref:`snapshots <internals-snapshot>` that contain on-disk copy of the entire data set for a given moment
10+
(``.snap`` files). It is possible to set automatic snapshot creation using the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>`.
1011

1112
During the recovery process, Tarantool can load the latest snapshot file and then read the requests from the WAL files,
1213
produced after this snapshot was made.
@@ -23,6 +24,34 @@ Configure the snapshots
2324

2425
This section describes how to define snapshot settings in the :ref:`snapshot <configuration_reference_snapshot>` section of a YAML configuration.
2526

27+
.. _configuration_persistence_snapshot_creation:
28+
29+
Configure the automatic snapshot creation
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
In Tarantool, it is possible to set automatic :ref:`snapshot creation </reference/reference_lua/box_snapshot>`.
33+
To enable it, the :ref:`snapshot.by.interval <configuration_reference_snapshot_by_interval>` option is used.
34+
The option sets up the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>` that takes new snapshots
35+
every ``snapshot.by.interval`` seconds.
36+
When the number of snapshots reaches the limit of :ref:`snapshot.count <configuration_reference_snapshot_count>` size,
37+
the daemon activates Tarantool garbage collector after the new snapshot is taken.
38+
Tarantool garbage collector deletes the oldest snapshot file and any associated WAL files.
39+
40+
The :ref:`snapshot.by.wal_size <configuration_reference_snapshot_by_wal_size>` option defines the maximum size in bytes
41+
for of all WAL files created since the last snapshot taken.
42+
Once this size is exceeded, the checkpoint daemon takes a snapshot and deletes the old WAL files.
43+
44+
The configuration of the checkpoint daemon might look as follows:
45+
46+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/persistence_snapshot/config.yaml
47+
:language: yaml
48+
:start-at: count:
49+
:end-at: 60
50+
:dedent:
51+
52+
If the ``snapshot.by.interval`` option is set to zero, the checkpoint daemon is disabled.
53+
If the ``snapshot.count`` option is set to zero, the checkpoint daemon does not delete old snapshots.
54+
2655
.. _configuration_persistence_snapshot_dir:
2756

2857
Specify a directory for snapshot files
@@ -50,35 +79,6 @@ For example, you can place snapshots and write-ahead logs on different hard driv
5079
wal:
5180
dir: '/media/drive2/wals'
5281
53-
.. _configuration_persistence_checkpoint_daemon:
54-
55-
Configure the automatic snapshot creation
56-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57-
58-
In Tarantool, it is possible to set automatic :ref:`snapshot creation </reference/reference_lua/box_snapshot>`.
59-
To enable it, the :ref:`snapshot.by.interval <configuration_reference_snapshot_by_interval>` option is used.
60-
The option sets up the :ref:`checkpoint daemon <configuration_reference_checkpoint_daemon>` (snapshot daemon), which is
61-
a constantly running :ref:`fiber <app-fibers>`.
62-
The checkpoint daemon takes new snapshots every ``snapshot.by.interval`` seconds.
63-
When the number of snapshots reaches the limit of :ref:`snapshot.count <configuration_reference_snapshot_count>` size,
64-
the daemon activates Tarantool garbage collector after the new snapshot is taken.
65-
Tarantool garbage collector deletes the oldest snapshot file and any associated WAL files.
66-
67-
The :ref:`snapshot.by.wal_size <configuration_reference_snapshot_by_wal_size>` option defines the maximum size in bytes
68-
for of all WAL files created since the last snapshot taken.
69-
Once this size is exceeded, the checkpoint daemon takes a snapshot and deletes the old WAL files.
70-
71-
The configuration of the checkpoint daemon might look as follows:
72-
73-
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/persistence_snapshot/config.yaml
74-
:language: yaml
75-
:start-at: count:
76-
:end-at: 60
77-
:dedent:
78-
79-
If the ``snapshot.by.interval`` option is set to zero, the checkpoint daemon is disabled.
80-
If the ``snapshot.count`` option is set to zero, the checkpoint daemon does not delete old snapshots.
81-
8282
.. _configuration_persistence_wal:
8383

8484
Configure the write-ahead log
@@ -157,7 +157,7 @@ size. The configuration for this option might look as follows:
157157
Set a delay for the garbage collector
158158
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159159

160-
In Tarantool, the :ref:`checkpoint daemon <configuration_reference_checkpoint_daemon>` (snapshot daemon)
160+
In Tarantool, the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>`
161161
takes new snapshots at the given interval (see :ref:`snapshot.by.interval <configuration_reference_snapshot_by_interval>`).
162162
After an instance restart, the daemon activates the Tarantool garbage collector that deletes the old WAL files.
163163

@@ -184,3 +184,50 @@ In Tarantool Enterprise, you can store an old and new tuple for each crud operat
184184
The detailed description and examples of the WAL extensions are provided in the :ref:`WAL extensions <wal_extensions>` section.
185185

186186
See also: :ref:`wal.ext.* <configuration_reference_wal_ext>` configuration options.
187+
188+
.. _configuration_persistence_checkpoint_daemon:
189+
190+
Checkpoint daemon
191+
-----------------
192+
193+
The checkpoint daemon (snapshot daemon) is a constantly running :ref:`fiber <app-fibers>`.
194+
If the checkpoint daemon is enabled, it takes new :ref:`snapshot (.snap) files <index-box_persistence>` at the
195+
:ref:`given interval <configuration_reference_snapshot_by_interval>` automatically.
196+
If necessary, the checkpoint daemon also activates the Tarantool garbage collector that deletes old snapshot and WAL files.
197+
198+
.. NOTE::
199+
200+
This garbage collector is distinct from the `Lua garbage collector <https://www.lua.org/manual/5.1/manual.html#2.10>`_
201+
which is for Lua objects, and distinct from the Tarantool garbage collector that specializes in :ref:`handling shard buckets <vshard-gc>`.
202+
203+
This garbage collector is called as follows:
204+
205+
* When the number of snapshots reaches the limit of :ref:`snapshot.count <configuration_reference_snapshot_count>` size.
206+
After a new snapshot is taken, Tarantool garbage collector deletes the oldest snapshot file and any associated WAL files.
207+
208+
* When the size all WAL files created since the last snapshot reaches the limit of :ref:`snapshot.by.wal_size <configuration_reference_snapshot_by_wal_size>`.
209+
Once this size is exceeded, the checkpoint daemon takes a snapshot, then the garbage collector deletes the old WAL files.
210+
211+
If the checkpoint daemon deletes an old snapshot file, the Tarantool garbage collector also deletes
212+
any :ref:`write-ahead log (.xlog) <internals-wal>` files that meet the following conditions:
213+
214+
* The WAL files are older than the snapshot file.
215+
* The WAL files contain information present in the snapshot file.
216+
217+
Tarantool garbage collector also deletes obsolete vinyl ``.run`` files.
218+
219+
The checkpoint daemon and the Tarantool garbage collector don't delete a file in the following cases:
220+
221+
* A **backup** is running, and the file has not been backed up
222+
(see :ref:`"Hot backup" <admin-backups-hot_backup_vinyl_memtx>`).
223+
224+
* **Replication** is running, and the file has not been relayed to a replica
225+
(see :ref:`"Replication architecture" <replication-architecture>`),
226+
227+
* A replica is connecting.
228+
229+
* A replica has fallen behind.
230+
The progress of each replica is tracked; if a replica's position is far
231+
from being up to date, then the server stops to give it a chance to catch up.
232+
If an administrator concludes that a replica is permanently down, then the
233+
correct procedure is to restart the server, or (preferably) :ref:`remove the replica from the cluster <replication-remove_instances>`.

doc/reference/configuration/configuration_reference.rst

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,9 +2404,9 @@ To learn more about the snapshots' configuration, check the :ref:`Persistence <c
24042404

24052405
- :ref:`snapshot.dir <configuration_reference_snapshot_dir>`
24062406
- :ref:`snapshot.snap_io_rate_limit <configuration_reference_snapshot_snap_io_rate_limit>`
2407-
- :ref:`checkpoint daemon <configuration_reference_checkpoint_daemon>`
2407+
- :ref:`snapshot.count <configuration_reference_snapshot_count>`
2408+
- :ref:`snapshot.by.* <configuration_reference_snapshot_by>`
24082409

2409-
- :ref:`snapshot.count <configuration_reference_snapshot_count>`
24102410
- :ref:`snapshot.by.interval <configuration_reference_snapshot_by_interval>`
24112411
- :ref:`snapshot.by.wal_size <configuration_reference_snapshot_by_wal_size>`
24122412

@@ -2442,52 +2442,13 @@ To learn more about the snapshots' configuration, check the :ref:`Persistence <c
24422442
| Default: box.NULL
24432443
| Environment variable: TT_SNAPSHOT_SNAP_IO_RATE_LIMIT
24442444
2445-
.. _configuration_reference_checkpoint_daemon:
2446-
2447-
Checkpoint daemon
2448-
~~~~~~~~~~~~~~~~~
2449-
2450-
The checkpoint daemon is a constantly running :ref:`fiber <app-fibers>`.
2451-
At intervals, it may make new :ref:`snapshot (.snap) files <index-box_persistence>` and then delete old snapshot files.
2452-
The checkpoint daemon may activate the Tarantool garbage collector that deletes old files -- snapshot and WAL files.
2453-
2454-
.. NOTE::
2455-
2456-
This garbage collector is distinct from the `Lua garbage collector <https://www.lua.org/manual/5.1/manual.html#2.10>`_
2457-
which is for Lua objects, and distinct from the Tarantool garbage collector that specializes in :ref:`handling shard buckets <vshard-gc>`.
2458-
2459-
If the checkpoint daemon deletes an old snapshot file, the Tarantool garbage collector also deletes
2460-
any :ref:`write-ahead log (.xlog) <internals-wal>` files that meet the following conditions:
2461-
2462-
* The WAL files are older than the snapshot file.
2463-
* The WAL files contain information present in the snapshot file.
2464-
2465-
Tarantool garbage collector also deletes obsolete vinyl ``.run`` files.
2466-
2467-
The checkpoint daemon and the Tarantool garbage collector don't delete a file in the following cases:
2468-
2469-
* A **backup** is running, and the file has not been backed up
2470-
(see :ref:`"Hot backup" <admin-backups-hot_backup_vinyl_memtx>`).
2471-
2472-
* **Replication** is running, and the file has not been relayed to a replica
2473-
(see :ref:`"Replication architecture" <replication-architecture>`),
2474-
2475-
* A replica is connecting.
2476-
2477-
* A replica has fallen behind.
2478-
The progress of each replica is tracked; if a replica's position is far
2479-
from being up to date, then the server stops to give it a chance to catch up.
2480-
If an administrator concludes that a replica is permanently down, then the
2481-
correct procedure is to restart the server, or (preferably) :ref:`remove the replica from the cluster <replication-remove_instances>`.
2482-
2483-
24842445
.. _configuration_reference_snapshot_count:
24852446

24862447
.. confval:: snapshot.count
24872448

24882449
The maximum number of snapshots that may exist on the
24892450
:ref:`snapshot.dir <configuration_reference_snapshot_dir>` directory
2490-
before the checkpoint daemon deletes old snapshots.
2451+
before the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>` deletes old snapshots.
24912452
If ``snapshot.count`` equals zero, then the checkpoint daemon
24922453
does not delete old snapshots.
24932454

@@ -2514,11 +2475,16 @@ The checkpoint daemon and the Tarantool garbage collector don't delete a file in
25142475
| Default: 2
25152476
| Environment variable: TT_SNAPSHOT_COUNT
25162477
2478+
.. _configuration_reference_snapshot_by:
2479+
2480+
snapshot.by.*
2481+
~~~~~~~~~~~~~
2482+
25172483
.. _configuration_reference_snapshot_by_interval:
25182484

25192485
.. confval:: snapshot.by.interval
25202486

2521-
The interval in seconds between actions by the checkpoint daemon.
2487+
The interval in seconds between actions by the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>`.
25222488
If the option is set to a value greater than zero, and there is
25232489
activity which causes change to a database, then the checkpoint daemon calls
25242490
:doc:`box.snapshot() </reference/reference_lua/box_snapshot>` every ``snapshot.by.interval``
@@ -2546,7 +2512,7 @@ The checkpoint daemon and the Tarantool garbage collector don't delete a file in
25462512

25472513
The threshold for the total size in bytes of all WAL files created since the last snapshot taken.
25482514
Once the configured threshold is exceeded, the WAL thread notifies the
2549-
checkpoint daemon that it must make a new snapshot and delete old WAL files.
2515+
:ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>` that it must make a new snapshot and delete old WAL files.
25502516

25512517
|
25522518
| Type: integer
@@ -2581,7 +2547,7 @@ To learn more about the WAL configuration, check the :ref:`Persistence <configur
25812547

25822548
.. confval:: wal.cleanup_delay
25832549

2584-
The delay in seconds used to prevent the :ref:`checkpoint daemon <configuration_reference_checkpoint_daemon>`
2550+
The delay in seconds used to prevent the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>`
25852551
from immediately removing :ref:`write-ahead log <internals-wal>` files after a node restart.
25862552
This delay eliminates possible erroneous situations when the master deletes WALs
25872553
needed by :ref:`replicas <replication-roles>` after restart.

doc/reference/reference_lua/box_snapshot.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
Although ``box.snapshot()`` does not cause a fork, there is a separate fiber
4848
which may produce snapshots at regular intervals -- see the discussion of
49-
the :ref:`checkpoint daemon <book_cfg_checkpoint_daemon>`.
49+
the :ref:`checkpoint daemon <configuration_persistence_checkpoint_daemon>`.
5050

5151
**Example:**
5252

0 commit comments

Comments
 (0)