[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#7211) mdb inconsistency without LAZY_LOCKS

Full_Name: Hallvard B Furuseth
Version: master, af3a23a1ec93220be392a8ea6372475b7357c171
OS: Linux x86_64
Submission from: (NULL) (
Submitted by: hallvard

A write transaction can overwrite env->me_metas[]->mm_dbs, me_numdbs
and me_dbxs while another txn is copying them in mdb_txn_renew0(),
resulting in an inconsistent copy.

'#define LAZY_LOCKS 0' fixes it.  Without it, test054 dumps core with
this patch:

diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c
index b714119..5e22827 100644
--- a/libraries/libmdb/mdb.c
+++ b/libraries/libmdb/mdb.c
@@ -1519,2 +1519,4 @@ mdb_txn_renew0(MDB_txn *txn)
 	memcpy(txn->mt_dbs, env->me_metas[txn->mt_toggle]->mm_dbs, 2 *
+	if ((rand() & 1)) usleep(100000);
+	assert(!memcmp(txn->mt_dbs, env->me_metas[txn->mt_toggle]->mm_dbs, 2 *
 	if (txn->mt_numdbs > 2)

I'm sleeping for write transactions only since that's when the
inconsistent copy is written back to disk.