Skip to content

Commit 56a20bf

Browse files
Database hot standby (#4436)
1 parent 0df4408 commit 56a20bf

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
database:
8+
hot_standby: true
9+
wal:
10+
dir: /tmp/wals
11+
snapshot:
12+
dir: /tmp/snapshots
13+
iproto:
14+
listen:
15+
- uri: '127.0.0.1:3301'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
database:
8+
hot_standby: true
9+
wal:
10+
dir: /tmp/wals
11+
snapshot:
12+
dir: /tmp/snapshots
13+
iproto:
14+
listen:
15+
- uri: '127.0.0.1:3301'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:

doc/reference/configuration/configuration_reference.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,40 @@ The ``database`` section defines database-specific configuration parameters, suc
14281428

14291429
.. confval:: database.hot_standby
14301430

1431+
Whether to start the server in the hot standby mode.
1432+
This mode can be used to provide failover without :ref:`replication <replication>`.
1433+
1434+
Suppose there are two cluster applications.
1435+
Each cluster has one instance with the same configuration:
1436+
1437+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/hot_standby_1/config.yaml
1438+
:language: yaml
1439+
:dedent:
1440+
1441+
In particular, both instances use the same directory for storing write-ahead logs and snapshots.
1442+
1443+
When you start both cluster applications on the same machine, the instance from the first one will be the primary instance and the second will be the standby instance.
1444+
In the :ref:`logs <configuration_reference_log>` of the second cluster instance, you should see a notification:
1445+
1446+
.. code-block:: text
1447+
1448+
main/104/interactive I> Entering hot standby mode
1449+
1450+
This means that the standby instance is ready to take over if the primary instance goes down.
1451+
The standby instance initializes and tries to take a lock on a directory for storing write-ahead logs
1452+
but fails because the primary instance has made a lock on this directory.
1453+
1454+
If the primary instance goes down for any reason, the lock is released.
1455+
In this case, the standby instance succeeds in taking the lock and becomes the primary instance.
1456+
1457+
``database.hot_standby`` has no effect:
1458+
1459+
* If :ref:`wal.mode <configuration_reference_wal_mode>` is set to ``none``.
1460+
* If :ref:`wal.dir_rescan_delay <configuration_reference_wal_dir_rescan_delay>` is set to a large value on macOS or FreeBSD. On these platforms, the hot standby mode is designed so that the loop repeats every ``wal.dir_rescan_delay`` seconds.
1461+
* For spaces created with :ref:`engine <space_opts_engine>` set to ``vinyl``.
1462+
1463+
Examples on GitHub: `hot_standby_1 <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/hot_standby_1>`_, `hot_standby_2 <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/hot_standby_2>`_
1464+
14311465
|
14321466
| Type: boolean
14331467
| Default: false

0 commit comments

Comments
 (0)