mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 22:34:12 +08:00
mdbx: refine ending of read-only transactions.
Change-Id: I56d07d75e4f5f64fd34e5b780024c145eb8299ed
This commit is contained in:
parent
99e9956410
commit
4560ddcd1e
@ -4415,23 +4415,30 @@ static int mdbx_txn_end(MDBX_txn *txn, unsigned mode) {
|
|||||||
|
|
||||||
if (F_ISSET(txn->mt_flags, MDBX_RDONLY)) {
|
if (F_ISSET(txn->mt_flags, MDBX_RDONLY)) {
|
||||||
if (txn->to.reader) {
|
if (txn->to.reader) {
|
||||||
mdbx_ensure(env, /* paranoia is appropriate here */
|
MDBX_reader *slot = txn->to.reader;
|
||||||
txn->mt_txnid == txn->to.reader->mr_txnid.inconsistent &&
|
mdbx_assert(env, slot->mr_pid == env->me_pid);
|
||||||
txn->to.reader->mr_txnid.inconsistent >=
|
if (likely(!F_ISSET(txn->mt_flags, MDBX_TXN_FINISHED))) {
|
||||||
env->me_lck->mti_oldest_reader);
|
mdbx_assert(env, txn->mt_txnid == slot->mr_txnid.inconsistent &&
|
||||||
txn->to.reader->mr_snapshot_pages_used = 0;
|
slot->mr_txnid.inconsistent >=
|
||||||
safe64_reset(&txn->to.reader->mr_txnid);
|
env->me_lck->mti_oldest_reader);
|
||||||
|
#if defined(MDBX_USE_VALGRIND) || defined(__SANITIZE_ADDRESS__)
|
||||||
|
mdbx_txn_valgrind(env, nullptr);
|
||||||
|
#endif
|
||||||
|
slot->mr_snapshot_pages_used = 0;
|
||||||
|
safe64_reset(&slot->mr_txnid);
|
||||||
|
env->me_lck->mti_readers_refresh_flag = true;
|
||||||
|
mdbx_flush_noncoherent_cpu_writeback();
|
||||||
|
} else {
|
||||||
|
mdbx_assert(env, slot->mr_pid == env->me_pid);
|
||||||
|
mdbx_assert(env,
|
||||||
|
slot->mr_txnid.inconsistent >= SAFE64_INVALID_THRESHOLD);
|
||||||
|
}
|
||||||
if (mode & MDBX_END_SLOT) {
|
if (mode & MDBX_END_SLOT) {
|
||||||
if ((env->me_flags & MDBX_ENV_TXKEY) == 0)
|
if ((env->me_flags & MDBX_ENV_TXKEY) == 0)
|
||||||
txn->to.reader->mr_pid = 0;
|
slot->mr_pid = 0;
|
||||||
txn->to.reader = NULL;
|
txn->to.reader = NULL;
|
||||||
}
|
}
|
||||||
env->me_lck->mti_readers_refresh_flag = true;
|
|
||||||
mdbx_flush_noncoherent_cpu_writeback();
|
|
||||||
}
|
}
|
||||||
#if defined(MDBX_USE_VALGRIND) || defined(__SANITIZE_ADDRESS__)
|
|
||||||
mdbx_txn_valgrind(env, nullptr);
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
if (txn->mt_flags & MDBX_SHRINK_ALLOWED)
|
if (txn->mt_flags & MDBX_SHRINK_ALLOWED)
|
||||||
mdbx_srwlock_ReleaseShared(&env->me_remap_guard);
|
mdbx_srwlock_ReleaseShared(&env->me_remap_guard);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user