mdbx: refine retired-next-reader insode mdbx_txn_info().

Change-Id: Iba57365cc4b7f4f09a0698502bc7aafcb6e67478
This commit is contained in:
Leonid Yuriev 2019-09-28 11:23:20 +03:00
parent dcd3c497d9
commit 86496e4480
2 changed files with 15 additions and 9 deletions

14
mdbx.h
View File

@ -2132,13 +2132,13 @@ typedef struct MDBX_txn_info {
For WRITE transaction: the space inside transaction
that left to MDBX_TXN_FULL error. */
uint64_t
txn_space_dirty; /* For READ-ONLY transaction (provided if scan_rlt=true):
The retired distance for next more recent reader, i.e.
the space that actually become available for reuse
when only this transaction will be finished. For WRITE
transaction: The summarized size of the dirty database
pages that generated during this transaction. */
uint64_t txn_space_dirty; /* For READ-ONLY transaction (provided if
scan_rlt=true): The space that actually become
available for reuse when only this transaction
will be finished.
For WRITE transaction: The summarized size of the
dirty database pages that generated during this
transaction. */
} MDBX_txn_info;
/* Return information about the MDBX transaction.

View File

@ -4104,6 +4104,7 @@ int mdbx_txn_info(MDBX_txn *txn, MDBX_txn_info *info, int scan_rlt) {
env, (pgno_t)(head_retired -
txn->mt_ro_reader->mr_snapshot_pages_retired));
size_t retired_next_reader = 0;
MDBX_lockinfo *const lck = env->me_lck;
if (scan_rlt && info->txn_reader_lag > 1 && lck) {
/* find next more recent reader */
@ -4122,15 +4123,20 @@ int mdbx_txn_info(MDBX_txn *txn, MDBX_txn_info *info, int scan_rlt) {
lck->mti_readers[i].mr_snapshot_pages_retired) ||
snap_txnid != safe64_read(&lck->mti_readers[i].mr_txnid))
goto retry;
if (snap_txnid > txn->mt_txnid && snap_txnid < next_reader) {
if (snap_txnid <= txn->mt_txnid) {
retired_next_reader = 0;
break;
}
if (snap_txnid < next_reader) {
next_reader = snap_txnid;
info->txn_space_dirty = pgno2bytes(
retired_next_reader = pgno2bytes(
env, (pgno_t)(snap_retired -
txn->mt_ro_reader->mr_snapshot_pages_retired));
}
}
}
}
info->txn_space_dirty = retired_next_reader;
}
} else {
info->txn_space_limit_soft = pgno2bytes(env, txn->mt_geo.now);