Skip to content

Commit 45e1300

Browse files
authored
Describe box.ctl.demote() function (#3162)
1 parent 5b17a5d commit 45e1300

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

doc/reference/reference_lua/box_ctl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Below is a list of all ``box.ctl`` functions.
5353
* - :doc:`./box_ctl/promote`
5454
- Wait, then choose replication leader
5555

56+
* - :doc:`./box_ctl/demote`
57+
- Revoke the leader role from the instance
58+
5659
.. toctree::
5760
:hidden:
5861

@@ -63,3 +66,4 @@ Below is a list of all ``box.ctl`` functions.
6366
box_ctl/set_on_shutdown_timeout
6467
box_ctl/is_recovery_finished
6568
box_ctl/promote
69+
box_ctl/demote
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. _box_ctl-demote:
2+
3+
box.ctl.demote()
4+
=================
5+
6+
.. function:: demote()
7+
8+
Since version :doc:`2.10.0 </release/2.10.0>`.
9+
10+
Revoke the leader role from the instance.
11+
12+
On :ref:`synchronous transaction queue owner <box_info_synchro>`, the function works in the following way:
13+
14+
* If :ref:`box.cfg.election_mode <cfg_replication-election_mode>` is ``off``,
15+
the function writes a ``DEMOTE`` request to WAL.
16+
The ``DEMOTE`` request clears the ownership of the synchronous transaction queue,
17+
while the ``PROMOTE`` request assigns it to a new instance.
18+
19+
* If :ref:`box.cfg.election_mode <cfg_replication-election_mode>` is enabled in any mode, then the function
20+
makes the instance start a new term and give up the leader role.
21+
22+
On instances that are not queue owners, the function does nothing and returns immediately.
23+
24+
Parameters: none
25+
26+
:return: nil

doc/reference/reference_lua/box_ctl/is_recovery_finished.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ box.ctl.is_recovery_finished()
88

99
.. function:: is_recovery_finished()
1010

11+
Since version :doc:`2.5.3 </release/2.5.3>`.
12+
1113
Check whether the :ref:`recovery process <internals-recovery_process>` has finished.
1214
Until it has finished, space changes such as ``insert`` or ``update`` are not possible.
1315

1416
:return: ``true`` if recovery has finished, otherwise ``false``
1517
:rtype: boolean
16-
17-
Added in release :doc:`2.5.3 </release/2.5.3>`.
1818

1919

2020

doc/reference/reference_lua/box_ctl/promote.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ box.ctl.promote()
55

66
.. function:: promote()
77

8+
Since version :doc:`2.6.2 </release/2.6.2>`.
9+
Renamed in release :doc:`2.6.3 </release/2.6.3>`.
10+
811
Wait, then choose new replication leader.
912

1013
For :ref:`synchronous transactions <how-to-repl_sync>` it is
@@ -20,5 +23,3 @@ box.ctl.promote()
2023
Parameters: none
2124

2225
:return: nil or function pointer
23-
24-
Added in release :doc:`2.6.2 </release/2.6.2>`. Renamed in release :doc:`2.6.3 </release/2.6.3>`.

doc/reference/reference_lua/box_info/synchro.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ box.info.synchro
99
.. data:: synchro
1010

1111
Since version :doc:`2.8.1 </release/2.8.1>`.
12+
1213
Show the current state of synchronous replication.
1314

1415
In :ref:`synchronous replication <repl_sync>`, transaction is considered committed only after achieving
@@ -26,6 +27,7 @@ box.info.synchro
2627
To claim or reclaim the queue, use :ref:`box.ctl.promote() <box_ctl-promote>` on the instance that you want
2728
to promote.
2829
With elections enabled, an instance runs ``box.ctl.promote()`` command automatically after winning the elections.
30+
To clear the ownership, call :ref:`box.ctl.demote() <box_ctl-demote>` on the synchronous queue owner.
2931

3032
- ``term`` (since version :doc:`2.10.0 </release/2.10.0>`) -- current queue term.
3133
It contains the term of the last ``PROMOTE`` request.

0 commit comments

Comments
 (0)