Skip to content

Describe box.ctl.demote() function #3162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/reference/reference_lua/box_ctl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Below is a list of all ``box.ctl`` functions.
* - :doc:`./box_ctl/promote`
- Wait, then choose replication leader

* - :doc:`./box_ctl/demote`
- Revoke the leader role from the instance

.. toctree::
:hidden:

Expand All @@ -63,3 +66,4 @@ Below is a list of all ``box.ctl`` functions.
box_ctl/set_on_shutdown_timeout
box_ctl/is_recovery_finished
box_ctl/promote
box_ctl/demote
26 changes: 26 additions & 0 deletions doc/reference/reference_lua/box_ctl/demote.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _box_ctl-demote:

box.ctl.demote()
=================

.. function:: demote()

Since version :doc:`2.10.0 </release/2.10.0>`.

Revoke the leader role from the instance.

On :ref:`synchronous transaction queue owner <box_info_synchro>`, the function works in the following way:

* If :ref:`box.cfg.election_mode <cfg_replication-election_mode>` is ``off``,
the function writes a ``DEMOTE`` request to WAL.
The ``DEMOTE`` request clears the ownership of the synchronous transaction queue,
while the ``PROMOTE`` request assigns it to a new instance.

* If :ref:`box.cfg.election_mode <cfg_replication-election_mode>` is enabled in any mode, then the function
makes the instance start a new term and give up the leader role.

On instances that are not queue owners, the function does nothing and returns immediately.

Parameters: none

:return: nil
4 changes: 2 additions & 2 deletions doc/reference/reference_lua/box_ctl/is_recovery_finished.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ box.ctl.is_recovery_finished()

.. function:: is_recovery_finished()

Since version :doc:`2.5.3 </release/2.5.3>`.

Check whether the :ref:`recovery process <internals-recovery_process>` has finished.
Until it has finished, space changes such as ``insert`` or ``update`` are not possible.

:return: ``true`` if recovery has finished, otherwise ``false``
:rtype: boolean

Added in release :doc:`2.5.3 </release/2.5.3>`.



Expand Down
5 changes: 3 additions & 2 deletions doc/reference/reference_lua/box_ctl/promote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ box.ctl.promote()

.. function:: promote()

Since version :doc:`2.6.2 </release/2.6.2>`.
Renamed in release :doc:`2.6.3 </release/2.6.3>`.

Wait, then choose new replication leader.

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

:return: nil or function pointer

Added in release :doc:`2.6.2 </release/2.6.2>`. Renamed in release :doc:`2.6.3 </release/2.6.3>`.
2 changes: 2 additions & 0 deletions doc/reference/reference_lua/box_info/synchro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ box.info.synchro
.. data:: synchro

Since version :doc:`2.8.1 </release/2.8.1>`.

Show the current state of synchronous replication.

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

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