Skip to content

Commit 0bea959

Browse files
committed
Update example
1 parent d995e8f commit 0bea959

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

doc/reference/reference_lua/box_info/synchro.rst

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ box.info.synchro
4646
Since version :doc:`2.5.3 </release/2.5.3>`, the option can be set as a dynamic formula.
4747
In this case, the value in the ``quorum`` member depends on the current number of replicas.
4848

49-
**Examples:**
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.
5054

5155
.. code-block:: tarantoolsession
5256
@@ -60,28 +64,51 @@ box.info.synchro
6064
quorum: 1
6165
...
6266
67+
**Example 2:**
68+
69+
//the description goes here
70+
71+
6372
.. code-block:: tarantoolsession
6473
74+
-- Set quorum number and timeout
6575
tarantool> box.cfg{replication_synchro_quorum=2, replication_synchro_timeout=1000}
6676
---
6777
...
68-
tarantool> s = box.schema.space.create("sync", {is_sync=true})
78+
79+
-- Check info about synchronous replication
80+
tarantool> box.info.synchro
6981
---
82+
- queue:
83+
owner: 0
84+
term: 0
85+
len: 0
86+
busy: false
87+
quorum: 2
7088
...
89+
90+
-- Create a space and enable synchronous replication on this space
91+
-- Create index
92+
tarantool> s = box.schema.space.create("sync", {is_sync=true})
7193
tarantool> _ = s:create_index('pk')
7294
---
7395
...
96+
97+
-- Claim the queue with the promote function
7498
tarantool> box.ctl.promote()
7599
2022-09-15 14:27:11.734 [74314] main/103/interactive I> RAFT: bump term to 2, follow
76100
2022-09-15 14:27:11.734 [74314] main/118/raft_worker I> RAFT: persisted state {term: 2}
77101
---
78102
...
103+
79104
tarantool> require('fiber').new(function() box.space.sync:replace{1} end)
80105
---
81106
- status: suspended
82107
name: lua
83108
id: 119
84109
...
110+
111+
-- Check the current state of synchronous replication.
85112
tarantool> box.info.synchro
86113
---
87114
- queue:
@@ -109,6 +136,9 @@ box.info.synchro
109136
name: lua
110137
id: 122
111138
...
139+
140+
-- Check the current state of synchronous replication.
141+
-- Now there are 4 transactions waiting in the queue.
112142
tarantool> box.info.synchro
113143
---
114144
- queue:

0 commit comments

Comments
 (0)