mirror of
https://github.com/isar/libmdbx.git
synced 2025-10-06 01:02:20 +08:00
mdbx: добавление режима MDBX_NOSTICKYTHREADS
вместо MDBX_NOTLS
.
This commit is contained in:
@@ -190,18 +190,20 @@ readers without writer" case.
|
||||
|
||||
|
||||
## One thread - One transaction
|
||||
A thread can only use one transaction at a time, plus any nested
|
||||
read-write transactions in the non-writemap mode. Each transaction
|
||||
belongs to one thread. The \ref MDBX_NOTLS flag changes this for read-only
|
||||
transactions. See below.
|
||||
A thread can only use one transaction at a time, plus any nested
|
||||
read-write transactions in the non-writemap mode. Each transaction
|
||||
belongs to one thread. The \ref MDBX_NOSTICKYTHREADS flag changes this,
|
||||
see below.
|
||||
|
||||
Do not start more than one transaction for a one thread. If you think
|
||||
about this, it's really strange to do something with two data snapshots
|
||||
at once, which may be different. MDBX checks and preventing this by
|
||||
returning corresponding error code (\ref MDBX_TXN_OVERLAPPING, \ref MDBX_BAD_RSLOT,
|
||||
\ref MDBX_BUSY) unless you using \ref MDBX_NOTLS option on the environment.
|
||||
Nonetheless, with the `MDBX_NOTLS` option, you must know exactly what you
|
||||
are doing, otherwise you will get deadlocks or reading an alien data.
|
||||
Do not start more than one transaction for a one thread. If you think
|
||||
about this, it's really strange to do something with two data snapshots
|
||||
at once, which may be different. MDBX checks and preventing this by
|
||||
returning corresponding error code (\ref MDBX_TXN_OVERLAPPING,
|
||||
\ref MDBX_BAD_RSLOT, \ref MDBX_BUSY) unless you using
|
||||
\ref MDBX_NOSTICKYTHREADS option on the environment.
|
||||
Nonetheless, with the `MDBX_NOSTICKYTHREADS` option, you must know
|
||||
exactly what you are doing, otherwise you will get deadlocks or reading
|
||||
an alien data.
|
||||
|
||||
|
||||
## Do not open twice
|
||||
|
@@ -129,20 +129,23 @@ no open MDBX-instance(s) during fork(), or at least close it immediately after
|
||||
necessary) in a child process would be both extreme complicated and so
|
||||
fragile.
|
||||
|
||||
Do not start more than one transaction for a one thread. If you think about
|
||||
this, it's really strange to do something with two data snapshots at once,
|
||||
which may be different. MDBX checks and preventing this by returning
|
||||
corresponding error code (\ref MDBX_TXN_OVERLAPPING, \ref MDBX_BAD_RSLOT, \ref MDBX_BUSY)
|
||||
unless you using \ref MDBX_NOTLS option on the environment. Nonetheless, with the
|
||||
\ref MDBX_NOTLS option, you must know exactly what you are doing, otherwise you
|
||||
will get deadlocks or reading an alien data.
|
||||
Do not start more than one transaction for a one thread. If you think
|
||||
about this, it's really strange to do something with two data snapshots
|
||||
at once, which may be different. MDBX checks and preventing this by
|
||||
returning corresponding error code (\ref MDBX_TXN_OVERLAPPING,
|
||||
\ref MDBX_BAD_RSLOT, \ref MDBX_BUSY) unless you using
|
||||
\ref MDBX_NOSTICKYTHREADS option on the environment. Nonetheless,
|
||||
with the \ref MDBX_NOSTICKYTHREADS option, you must know exactly what
|
||||
you are doing, otherwise you will get deadlocks or reading an alien
|
||||
data.
|
||||
|
||||
Also note that a transaction is tied to one thread by default using Thread
|
||||
Local Storage. If you want to pass read-only transactions across threads,
|
||||
you can use the \ref MDBX_NOTLS option on the environment. Nevertheless, a write
|
||||
transaction entirely should only be used in one thread from start to finish.
|
||||
MDBX checks this in a reasonable manner and return the \ref MDBX_THREAD_MISMATCH
|
||||
error in rules violation.
|
||||
Also note that a transaction is tied to one thread by default using
|
||||
Thread Local Storage. If you want to pass transactions across threads,
|
||||
you can use the \ref MDBX_NOSTICKYTHREADS option on the environment.
|
||||
Nevertheless, a write transaction must be committed or aborted in the
|
||||
same thread which it was started. MDBX checks this in a reasonable
|
||||
manner and return the \ref MDBX_THREAD_MISMATCH error in rules
|
||||
violation.
|
||||
|
||||
|
||||
## Transactions, rollbacks etc
|
||||
|
Reference in New Issue
Block a user