New transaction isolation level - linearizable #3167
Labels
2.11
2.11 release and the associated technical debt
concepts
feature
A new functionality
mvcc
transactions
[area] Related to Transactions
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
withtxn_isolation = 'linearizable'
, but youcan'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
isthe count of registered nodes in the cluster and
Q
isreplication_synchro_quorum
value (the same asbox.info.synchro.quorum
). This is the implementation limitation. Forexample, 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 ofbox.begin()
, anerror 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
See also
https://www.tarantool.io/en/doc/latest/release/2.11.0/#linearizable-read
The text was updated successfully, but these errors were encountered: