-
Notifications
You must be signed in to change notification settings - Fork 43
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
Comments
Please cross-link to "Binary protocol": |
Add links to transaction isolation docs to box_protocol.rst (IPROTO_BEGIN subsection) |
This article by Konstantin Osipov may be useful to learn about the basics of transaction isolation: |
Thanks! |
Resolves #2793 Co-authored-by: Dia Patience Daur <[email protected]>
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:
(box.commit() was called) are visible.
(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:
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.
The text was updated successfully, but these errors were encountered: