mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 19:24:13 +08:00
mdbx: fix snap-state bug (backport).
Change-Id: Ia0f2e028193d223b3a25e76d83cb22b9bc9546e6
This commit is contained in:
parent
bb205df001
commit
baf0fad11d
21
mdb.c
21
mdb.c
@ -2898,23 +2898,22 @@ mdb_txn_renew0(MDB_txn *txn, unsigned flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while((env->me_flags & MDB_FATAL_ERROR) == 0) {
|
while((env->me_flags & MDB_FATAL_ERROR) == 0) {
|
||||||
MDB_meta *meta = mdb_meta_head_r(txn->mt_env);
|
MDB_meta * const meta = mdb_meta_head_r(txn->mt_env);
|
||||||
txnid_t lead = meta->mm_txnid;
|
const txnid_t lead = meta->mm_txnid;
|
||||||
r->mr_txnid = lead;
|
r->mr_txnid = lead;
|
||||||
mdbx_coherent_barrier();
|
mdbx_coherent_barrier();
|
||||||
|
|
||||||
txnid_t snap = txn->mt_env->me_txns->mti_txnid;
|
txn->mt_txnid = lead;
|
||||||
/* LY: Retry on a race, ITS#7970. */
|
txn->mt_next_pgno = meta->mm_last_pg+1;
|
||||||
if (likely(lead == snap)) {
|
/* Copy the DB info and flags */
|
||||||
txn->mt_txnid = lead;
|
memcpy(txn->mt_dbs, meta->mm_dbs, CORE_DBS * sizeof(MDB_db));
|
||||||
txn->mt_next_pgno = meta->mm_last_pg+1;
|
|
||||||
/* Copy the DB info and flags */
|
|
||||||
memcpy(txn->mt_dbs, meta->mm_dbs, CORE_DBS * sizeof(MDB_db));
|
|
||||||
#if MDBX_MODE_ENABLED
|
#if MDBX_MODE_ENABLED
|
||||||
txn->mt_canary = meta->mm_canary;
|
txn->mt_canary = meta->mm_canary;
|
||||||
#endif
|
#endif
|
||||||
|
/* LY: Retry on a race, ITS#7970. */
|
||||||
|
const txnid_t snap = txn->mt_env->me_txns->mti_txnid;
|
||||||
|
if (likely(lead == snap))
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
txn->mt_u.reader = r;
|
txn->mt_u.reader = r;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user