mdbx: fix snap-state bug (backport).

Change-Id: Ia0f2e028193d223b3a25e76d83cb22b9bc9546e6
This commit is contained in:
Leo Yuriev 2017-04-27 01:50:19 +03:00
parent bb205df001
commit baf0fad11d

11
mdb.c
View File

@ -2898,14 +2898,11 @@ 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;
/* LY: Retry on a race, ITS#7970. */
if (likely(lead == snap)) {
txn->mt_txnid = lead; txn->mt_txnid = lead;
txn->mt_next_pgno = meta->mm_last_pg+1; txn->mt_next_pgno = meta->mm_last_pg+1;
/* Copy the DB info and flags */ /* Copy the DB info and flags */
@ -2913,9 +2910,11 @@ mdb_txn_renew0(MDB_txn *txn, unsigned flags)
#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;
txn->mt_dbxs = env->me_dbxs; /* mostly static anyway */ txn->mt_dbxs = env->me_dbxs; /* mostly static anyway */