11.. _repl_sync :
22
3- ================================================================================
43Synchronous replication
5- ================================================================================
4+ =======================
65
7- --------------------------------------------------------------------------------
86Overview
9- --------------------------------------------------------------------------------
7+ --------
108
119By default, replication in Tarantool is **asynchronous **: if a transaction
1210is committed locally on a master node, it does not mean it is replicated onto any
@@ -17,14 +15,13 @@ to a replica, from the client's point of view the transaction will disappear.
1715are not considered committed and are not responded to a client until they are
1816replicated onto some number of replicas.
1917
20- --------------------------------------------------------------------------------
2118Usage
22- --------------------------------------------------------------------------------
19+ -----
2320
2421Since version :doc: `2.5.1 </release/2.5.1 >`,
2522synchronous replication can be enabled per-space by using the ``is_sync `` option:
2623
27- .. code-block :: lua
24+ .. code-block :: lua
2825
2926 box.schema.create_space('test1', {is_sync = true})
3027
@@ -34,15 +31,15 @@ Notice that DDL on this space (including truncation) is **not** synchronous.
3431To control the behavior of synchronous transactions, there exist global
3532``box.cfg `` :ref: `options <cfg_replication-replication_synchro_quorum >`:
3633
37- .. code-block :: lua
34+ .. code-block :: lua
3835
3936 box.cfg{replication_synchro_quorum = <number of instances>}
4037
4138 This option tells how many replicas should confirm the receipt of a synchronous
42- transaction before it is committed. So far, this option accounts for all
43- replicas including anonymous ones . As a usage example, consider this:
39+ transaction before it is committed. Since version :doc: ` 2.10.0 < /release/2.10.0 >`,
40+ this option does not account for anonymous replicas . As a usage example, consider this:
4441
45- .. code-block :: lua
42+ .. code-block :: lua
4643
4744 -- Instance 1
4845 box.cfg{
@@ -53,15 +50,15 @@ replicas including anonymous ones. As a usage example, consider this:
5350 _ = box.schema.space.create('sync', {is_sync=true})
5451 _ = _:create_index('pk')
5552
56- .. code-block :: lua
53+ .. code-block :: lua
5754
5855 -- Instance 2
5956 box.cfg{
6057 listen = 3314,
6158 replication = 'localhost:3313'
6259 }
6360
64- .. code-block :: lua
61+ .. code-block :: lua
6562
6663 -- Instance 1
6764 box.space.sync:replace{1}
@@ -74,12 +71,12 @@ replica. This is because the master instance itself also participates in the quo
7471Now, if the second instance is down, the first one won't be able to commit any
7572synchronous change.
7673
77- .. code-block :: lua
74+ .. code-block :: lua
7875
7976 -- Instance 2
8077 Ctrl+D
8178
82- .. code-block :: tarantoolsession
79+ .. code-block :: tarantoolsession
8380
8481 -- Instance 1
8582 tarantool> box.space.sync:replace{2}
@@ -90,7 +87,7 @@ synchronous change.
9087 The transaction wasn't committed because it failed to achieve the quorum in the
9188given time. The time is a second configuration option:
9289
93- .. code-block :: lua
90+ .. code-block :: lua
9491
9592 box.cfg{replication_synchro_timeout = <number of seconds, can be float>}
9693
@@ -104,9 +101,8 @@ The ``timeout`` and ``quorum`` options are not used on replicas. It means if
104101the master dies, the pending synchronous transactions will be kept waiting on
105102the replicas until a new master is elected.
106103
107- --------------------------------------------------------------------------------
108104Synchronous and asynchronous transactions
109- --------------------------------------------------------------------------------
105+ -----------------------------------------
110106
111107A killer feature of Tarantool's synchronous replication is its being *per-space *.
112108So, if you need it only rarely for some critical data changes, you won't pay for
@@ -134,9 +130,8 @@ This just means it will wait for the synchronous transaction to be committed.
134130But once it is done, the asynchronous transaction will be committed
135131immediately—it won't wait for being replicated itself.
136132
137- --------------------------------------------------------------------------------
138133Limitations and known problems
139- --------------------------------------------------------------------------------
134+ ------------------------------
140135
141136Until version :doc: `2.5.2 </release/2.5.2 >`,
142137there was no way to enable synchronous replication for
@@ -146,22 +141,18 @@ existing spaces, but since 2.5.2 it can be enabled by
146141Synchronous transactions work only for master-slave topology. You can have multiple
147142replicas, anonymous replicas, but only one node can make synchronous transactions.
148143
149- Anonymous replicas participate in the quorum.
150- However, this will change: it won't be possible
151- for a synchronous transaction to gather quorum using anonymous replicas in the future.
144+ Since Tarantool :doc: `2.10.0 </release/2.10.0 >`, anonymous replicas do not participate in the quorum.
152145
153- --------------------------------------------------------------------------------
154146Leader election
155- --------------------------------------------------------------------------------
147+ ---------------
156148
157149Starting from version :doc: `2.6.1 </release/2.6.1 >`,
158150Tarantool has the built-in functionality
159151managing automated leader election in a replica set. For more information,
160152refer to the :ref: `corresponding chapter <repl_leader_elect >`.
161153
162- --------------------------------------------------------------------------------
163154Tips and tricks
164- --------------------------------------------------------------------------------
155+ ---------------
165156
166157If a transaction is rolled back, it does not mean the ROLLBACK message reached
167158the replicas. It still can happen that the master node suddenly dies, so the
0 commit comments