Description
Product: Tarantool
Since: 2.11
Audience/target: dev
Root documents:
https://www.tarantool.io/en/doc/latest/concepts/atomic/transaction_model/
https://www.tarantool.io/en/doc/latest/concepts/atomic/txn_mode_mvcc/
https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_txn_management/begin/
SME: @ sergepetrenko
Details
There is a new transaction isolation level - linearizable.
You may call box.begin
with txn_isolation = 'linearizable'
, but you
can't set the default transaction isolation level to 'linearizable'.
Linearizable transactions may only perform requests to synchronous,
local or temporary memtx spaces (vinyl engine support will be added
later).
Starting a linearizable transaction requires
box.cfg.memtx_use_mvcc_engine
to be on.
Note: starting a linearizable transaction requires that the node is the
replication source for at least N - Q + 1 remote replicas. Here N
is
the count of registered nodes in the cluster and Q
is
replication_synchro_quorum
value (the same as
box.info.synchro.quorum
). This is the implementation limitation. For
example, you may start linearizable transactions on any node of a
cluster in full-mesh topology, but you can't perform linearizable
transactions on anonymous replicas, because noone replicates from
them.
When a transcaction is linearizable it sees the latest changes performed
on the quorum of nodes in the cluster. For example, if you use
linearizable transactions to read data on a replica, such a transaction
will never read stale data: all the committed writes performed on the
master will be seen by the transaction.
Making a transaction linearizable requires some waiting until the node
receives all the committed data. In case the node can't contact enough
remote peers to determine which data is committed an error is returned.
Waiting for committed data may time out: if the data isn't received
during the timeout specified by timeout
option of box.begin()
, an
error is returned.
When called with {txn_isolation = 'linearizable'}
, box.begin()
yields until the instance receives enough data from remote peers to be
sure that the transaction is linearizable.
Requested by @ sergepetrenko in tarantool/tarantool@70bf99c.
Definition of done
- MVCC doc page explains how the linearizable isolation level works
- box.begin reference contains the new possible level value.
See also
https://www.tarantool.io/en/doc/latest/release/2.11.0/#linearizable-read