11.. _box_info_synchro :
22
3- ================================================================================
43box.info.synchro
5- ================================================================================
4+ ================
65
76.. module :: box.info
87
@@ -29,6 +28,13 @@ box.info.synchro
2928 With elections enabled, an instance runs ``box.ctl.promote() `` command automatically after winning the elections.
3029 To clear the ownership, call :ref: `box.ctl.demote() <box_ctl-demote >` on the synchronous queue owner.
3130
31+ .. note ::
32+
33+ When Raft election is enabled and :ref: `replication.election_mode <configuration_reference_replication_election_mode >`
34+ is set to ``candidate ``, the new Raft leader claims the queue automatically.
35+ It means that the value of ``box.info.synchro.queue.owner `` becomes equal to :ref: `box.info.election.leader <box_info_election >`.
36+ When Raft enabled, no manual intervention with ``box.ctl.promote() `` or ``box.ctl.demote() `` is required.
37+
3238 - ``term `` (since version :doc: `2.10.0 </release/2.10.0 >`) -- current queue term.
3339 It contains the term of the last ``PROMOTE `` request.
3440 Usually, it is equal to :ref: `box.info.election.term <box_info_election >`.
@@ -43,49 +49,58 @@ box.info.synchro
4349 Until the request is complete, any other incoming synchronous transactions and system requests
4450 will be delayed.
4551
52+ - ``age `` (since version :doc: `3.2.0 </release/3.2.0 >`) -- the time in seconds that the oldest entry currently
53+ present in the queue has spent waiting for the quorum to collect.
54+
55+ - ``confirm_lag `` (since version :doc: `3.2.0 </release/3.2.0 >`) -- the time in seconds that the latest successfully
56+ confirmed entry waited for the quorum to collect.
57+
4658 * ``quorum `` -- the resulting value of the
4759 :ref: `replication_synchro_quorum <cfg_replication-replication_synchro_quorum >` configuration option.
4860 Since version :doc: `2.5.3 </release/2.5.3 >`, the option can be set as a dynamic formula.
4961 In this case, the value of the ``quorum `` member depends on the current number of replicas.
5062
5163 **Example 1: **
5264
53- In this example, the ``quorum `` field is equal to `` 1 ` `.
65+ In this example, the ``quorum `` field is equal to `1 `.
5466 That is, synchronous transactions work like asynchronous ones.
5567 `1 ` means that a successful WAL writing to the master is enough to commit.
5668
57- .. code-block :: tarantoolsession
69+ .. code-block :: console
5870
59- tarantool > box.info.synchro
71+ instance001 > box.info.synchro
6072 ---
6173 - queue:
6274 owner: 1
75+ confirm_lag: 0
6376 term: 2
77+ age: 0
6478 len: 0
6579 busy: false
6680 quorum: 1
6781 ...
6882
6983 **Example 2: **
7084
71- First, set a quorum number and a timeout for synchronous replication using the following command :
85+ First, set a quorum number and a timeout for synchronous replication in the configuration file (`` config.yaml ``) :
7286
73- .. code-block :: tarantoolsession
87+ .. code-block :: yaml
7488
75- tarantool> box.cfg{
76- > replication_synchro_quorum=2,
77- > replication_synchro_timeout=1000
78- > }
89+ replication :
90+ synchro_quorum : 2
91+ synchro_timeout : 1000
7992
80- Next, check the current state of synchronous replication:
93+ Check the current state of synchronous replication:
8194
82- .. code-block :: tarantoolsession
95+ .. code-block :: console
8396
84- tarantool > box.info.synchro
97+ app:instance001 > box.info.synchro
8598 ---
8699 - queue:
87- owner: 1
88- term: 2
100+ owner: 2
101+ confirm_lag: 0
102+ term: 28
103+ age: 0
89104 len: 0
90105 busy: false
91106 quorum: 2
@@ -94,51 +109,53 @@ box.info.synchro
94109 Create a space called ``sync `` and enable synchronous replication on this space.
95110 Then, create an index.
96111
97- .. code-block :: tarantoolsession
112+ .. code-block :: console
98113
99- tarantool > s = box.schema.space.create("sync", {is_sync=true})
100- tarantool > _ = s:create_index('pk')
114+ app:instance001 > s = box.schema.space.create("sync", {is_sync=true})
115+ app:instance001 > _ = s:create_index('pk')
101116
102117 After that, use ``box.ctl.promote() `` function to claim a queue:
103118
104- .. code-block :: tarantoolsession
119+ .. code-block :: console
105120
106- tarantool > box.ctl.promote()
121+ app:instance001 > box.ctl.promote()
107122
108123 Next, perform data manipulations:
109124
110- .. code-block :: tarantoolsession
125+ .. code-block :: console
111126
112- tarantool > require('fiber').new(function() box.space.sync:replace{1} end)
127+ app:instance001 > require('fiber').new(function() box.space.sync:replace{1} end)
113128 ---
114129 - status: suspended
115130 name: lua
116- id: 119
131+ id: 127
117132 ...
118- tarantool > require('fiber').new(function() box.space.sync:replace{1} end)
133+ app:instance001 > require('fiber').new(function() box.space.sync:replace{1} end)
119134 ---
120135 - status: suspended
121136 name: lua
122- id: 120
137+ id: 128
123138 ...
124- tarantool > require('fiber').new(function() box.space.sync:replace{1} end)
139+ app:instance001 > require('fiber').new(function() box.space.sync:replace{1} end)
125140 ---
126141 - status: suspended
127142 name: lua
128- id: 121
143+ id: 129
129144 ...
130145
131146 If you call the ``box.info.synchro `` command again,
132147 you will see that now there are 3 transactions waiting in the queue:
133148
134- .. code-block :: tarantoolsession
149+ .. code-block :: console
135150
136- tarantool > box.info.synchro
151+ app:instance001 > box.info.synchro
137152 ---
138153 - queue:
139154 owner: 1
140- term: 2
141- len: 3
155+ confirm_lag: 0
156+ term: 29
157+ age: 0
158+ len: 0
142159 busy: false
143160 quorum: 2
144- ...
161+ ...
0 commit comments