From 0b1f9b0f731d9c04efb9aa9e7272f637728d1653 Mon Sep 17 00:00:00 2001 From: Aleksandr Lyapunov <alyapunov@tarantool.org> Date: Mon, 21 Mar 2022 09:04:59 +0300 Subject: [PATCH] txm: add changelog and doc request @TarantoolBot document Title: Document transaction isolation settings All transactions in tarantool see only committed changes, but is a loose concept since the commit of a transaction is long-term act and there's a dilemma of choosing a timepoint at which the changes must be seen by other transactions. When enabled, mvcc engine allows some options on this field. To be specific we introduced two levels of isolaton: * read-committed: all transaction that have started committing (box.commit() was called) are visible. * read-confirmed: all transaction that have finished committing (box.commit() returnd) are visible. The first level is good for RW transactions since it allows to avoid some conflicts, while the second is good for RO transactions since it allows to get tuples that a definitely was perisisten on disk. There's also a default option that allows mvcc engine to decide: * best-effort: do the best depending of which actions the transaction has made. For autocommit transaction (one-statement actions without explicit box.begin/commit calls) an obvious rule is apllied: RO (select, get, count etc) transactions are done with read-confirmed; all other (replace, delete, etc) - read-committed. If a transaction has an explicit box.begin call, the level can be specified in the following way: box.begin({tnx_isolation = 'default'}) box.begin({txn_isolation = 'read-committed'}) box.begin({txn_isolation = 'read-confirmed'}) box.begin({tnx_isolation = 'best-effort'}) One can similarly set the level in net.box stream begin() method. If not specified (or if 'default' was passed) the level is taken from configuration. One can set default level in box.cfg: box.cfg({default_txn_isolation = 'read-committed'}) box.cfg({default_txn_isolation = 'read-confirmed'}) box.cfg({default_tnx_isolation = 'best-effort'}) The default option is 'best-effort'. In iproto the level is specified by IPROTO_TNX_ISOLATION key in the body of IPROTO_BEGIN request. The value is the one of the following enum values: enum txn_isolation_level { /** Take isolation level from global default level. */ TXN_ISOLATION_DEFAULT = 0, /** Allow to read committed, but not confirmed changes. */ TXN_ISOLATION_READ_COMMITTED = 1, /** Allow to read only confirmed changes. */ TXN_ISOLATION_READ_CONFIRMED = 2, /** Determine isolation level automatically. */ TXN_ISOLATION_BEST_EFFORD = 3, }; NO_TEST=no changes Closes #6930 --- changelogs/unreleased/gh-6930-isolation-level.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/unreleased/gh-6930-isolation-level.md diff --git a/changelogs/unreleased/gh-6930-isolation-level.md b/changelogs/unreleased/gh-6930-isolation-level.md new file mode 100644 index 0000000000..b6bb4902d4 --- /dev/null +++ b/changelogs/unreleased/gh-6930-isolation-level.md @@ -0,0 +1,3 @@ +## feature/core + +* Introduced transaction isolation levels in Lua and IPROTO (gh-6930). -- GitLab