@@ -20,17 +20,18 @@ box.info.synchro
20
20
* ``queue ``:
21
21
22
22
- ``owner `` -- ID of the replica that owns the synchronous transaction queue.
23
- Once the owner instance appears, all other instances become read-only.
23
+ Once an owner instance appears, all other instances become read-only.
24
24
If the ``owner `` field is ``0 ``, then every instance is writeable,
25
- but it can't create any synchronous transactions.
26
- To claim or re-claim the queue, use :ref: `box.ctl.promote() <box_ctl-promote >` on the instance that you want
25
+ but they can't create any synchronous transactions.
26
+ To claim or reclaim the queue, use :ref: `box.ctl.promote() <box_ctl-promote >` on the instance that you want
27
27
to promote.
28
+ With elections enabled, the instance runs ``box.ctl.promote() `` automatically after winning the elections.
28
29
Since version :doc: `2.10.0 </release/2.10.0 >`.
29
30
30
31
- ``term `` -- current queue term.
31
32
It contains the term of the last ``PROMOTE ``.
32
33
Usually it is equal to :ref: `box.info.election.term <box_info_election >`.
33
- However, the queue term value may be less than the corresponding one in election term.
34
+ However, the queue term value may be less than the corresponding one in the election term.
34
35
It can happen when a new round of elections started, but no one has promoted yet.
35
36
Since version :doc: `2.10.0 </release/2.10.0 >`.
36
37
@@ -45,13 +46,97 @@ box.info.synchro
45
46
Since version :doc: `2.5.3 </release/2.5.3 >`, the option can be set as a dynamic formula.
46
47
In this case, the value in the ``quorum `` member depends on the current number of replicas.
47
48
48
- **Example: **
49
+ **Example 1: **
50
+
51
+ In this example, the ``quorum `` field is equal to ``1 ``.
52
+ This means that the synchronous transactions work like asynchronous.
53
+ `1 ` means that successful WAL write to the master is enough to commit.
49
54
50
55
.. code-block :: tarantoolsession
51
56
52
57
tarantool> box.info.synchro
53
58
---
54
59
- queue:
60
+ owner: 1
61
+ term: 2
55
62
len: 0
63
+ busy: false
56
64
quorum: 1
65
+ ...
66
+
67
+ **Example 2: **
68
+
69
+ First, set a quorum number and a timeout for synchronous replication using the following command:
70
+
71
+ .. code-block :: tarantoolsession
72
+
73
+ tarantool> box.cfg{
74
+ > replication_synchro_quorum=2,
75
+ > replication_synchro_timeout=1000
76
+ > }
77
+
78
+ Next, check the current state of synchronous replication:
79
+
80
+ .. code-block :: tarantoolsession
81
+
82
+ tarantool> box.info.synchro
83
+ ---
84
+ - queue:
85
+ owner: 1
86
+ term: 2
87
+ len: 0
88
+ busy: false
89
+ quorum: 2
90
+ ...
91
+
92
+ Create a space called ``sync `` and enable synchronous replication on this space.
93
+ Then, create an index.
94
+
95
+ .. code-block :: tarantoolsession
96
+
97
+ tarantool> s = box.schema.space.create("sync", {is_sync=true})
98
+ tarantool> _ = s:create_index('pk')
99
+
100
+ After that, use ``box.ctl.promote `` function to claim the queue:
101
+
102
+ .. code-block :: tarantoolsession
103
+
104
+ tarantool> box.ctl.promote()
105
+
106
+ Next, use the ``replace `` command:
107
+
108
+ .. code-block :: tarantoolsession
109
+
110
+ tarantool> require('fiber').new(function() box.space.sync:replace{1} end)
111
+ ---
112
+ - status: suspended
113
+ name: lua
114
+ id: 119
115
+ ...
116
+ tarantool> require('fiber').new(function() box.space.sync:replace{1} end)
117
+ ---
118
+ - status: suspended
119
+ name: lua
120
+ id: 120
121
+ ...
122
+ tarantool> require('fiber').new(function() box.space.sync:replace{1} end)
123
+ ---
124
+ - status: suspended
125
+ name: lua
126
+ id: 121
127
+ ...
128
+
129
+ If you use the ``box.info.synchro `` command again,
130
+ you will see that now there are 3 transactions waiting in the queue:
131
+
132
+ .. code-block :: tarantoolsession
133
+
134
+ tarantool> box.info.synchro
135
+ ---
136
+ - queue:
137
+ owner: 1
138
+ term: 2
139
+ len: 3
140
+ busy: false
141
+ quorum: 2
57
142
...
0 commit comments