Skip to content

Document transaction isolation settings #2793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #2603
TarantoolBot opened this issue Apr 4, 2022 · 5 comments · Fixed by #2991
Closed
Tracked by #2603

Document transaction isolation settings #2793

TarantoolBot opened this issue Apr 4, 2022 · 5 comments · Fixed by #2991
Assignees
Labels
customer Reported by paying customers feature A new functionality
Milestone

Comments

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented Apr 4, 2022

Root document: https://www.tarantool.io/en/doc/latest/book/box/atomic/
https://www.tarantool.io/en/doc/latest/reference/
SME: @ Mons @ alyapunov

This ticket may require adding a new page.
Also, we may need to split the Transactions page into separate sections. Related issue: #2812

Details

This may require making graphs, as the topic is hard to understand from mere writing.


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 isolation:

  • 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 persistent on
disk.

There's also a default option that allows mvcc engine to decide:

  • best-effort: do the best depending on which actions the
    transaction has made.

For autocommit transaction (one-statement actions without explicit
box.begin/commit calls) an obvious rule is applied: 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_TXN_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_EFFORT = 3,
};

NO_TEST=no changes
Closes #6930
Requested by @alyapunov in tarantool/tarantool@0b1f9b0.

@xuniq xuniq added 5sp feature A new functionality labels Apr 18, 2022
@patiencedaur patiencedaur added the customer Reported by paying customers label May 27, 2022
@patiencedaur patiencedaur added this to the 2.10 milestone May 27, 2022
@patiencedaur
Copy link
Contributor

@p7nov
Copy link
Contributor

p7nov commented Jun 7, 2022

Add links to transaction isolation docs to box_protocol.rst (IPROTO_BEGIN subsection)

@rindblack15
Copy link
Contributor

Please note that information on transaction isolation will be described in this ticket: #2906 (#2934) and may largely cover the requirements of the current ticket.

@patiencedaur
Copy link
Contributor

This article by Konstantin Osipov may be useful to learn about the basics of transaction isolation:
https://habr.com/ru/company/oleg-bunin/blog/310560/

@p7nov p7nov self-assigned this Jun 29, 2022
@p7nov p7nov added 3sp and removed 5sp labels Jun 30, 2022
@p7nov
Copy link
Contributor

p7nov commented Jun 30, 2022

Please note that information on transaction isolation will be described in this ticket: #2906 (#2934) and may largely cover the requirements of the current ticket.

Thanks!
Lowered the estimation to 3sp because the concept is already explained in Transaction model and Transaction mode: MVCC.

p7nov added a commit that referenced this issue Jul 5, 2022
Resolves #2793 
Co-authored-by: Dia Patience Daur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer Reported by paying customers feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants