mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:44:12 +08:00
mdbx: fix/refine mdbx_find_largest().
Change-Id: Ib40ca0014da18793be0bdae5133806304ad42819
This commit is contained in:
parent
421f4b01e6
commit
4ecf78163d
15
src/mdbx.c
15
src/mdbx.c
@ -2207,12 +2207,19 @@ static pgno_t mdbx_find_largest(MDBX_env *env, pgno_t largest) {
|
||||
if (likely(lck != NULL /* exclusive mode */)) {
|
||||
const unsigned snap_nreaders = lck->mti_numreaders;
|
||||
for (unsigned i = 0; i < snap_nreaders; ++i) {
|
||||
retry:
|
||||
if (lck->mti_readers[i].mr_pid) {
|
||||
/* mdbx_jitter4testing(true); */
|
||||
const pgno_t snap = lck->mti_readers[i].mr_snapshot_pages;
|
||||
if (snap && snap >= largest &&
|
||||
lck->mti_oldest >= lck->mti_readers[i].mr_txnid)
|
||||
largest = snap;
|
||||
const pgno_t snap_pages = lck->mti_readers[i].mr_snapshot_pages;
|
||||
const txnid_t snap_txnid = lck->mti_readers[i].mr_txnid;
|
||||
mdbx_memory_barrier();
|
||||
if (unlikely(snap_pages != lck->mti_readers[i].mr_snapshot_pages ||
|
||||
snap_txnid != lck->mti_readers[i].mr_txnid))
|
||||
goto retry;
|
||||
if (largest < snap_pages &&
|
||||
lck->mti_oldest <= /* ignore pending updates */ snap_txnid &&
|
||||
snap_txnid <= env->me_txn0->mt_txnid)
|
||||
largest = snap_pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user