From: Howard Chu Date: Thu, 5 Jul 2012 23:40:46 +0000 (-0700) Subject: Partial revert of 13c663f666ac28d7a72cbe644d393fc8d2dd9881 X-Git-Tag: OPENLDAP_REL_ENG_2_4_32~61^2~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b802bcf7040110e1f0768d9d9ffa88dabd4bd5e7;p=openldap Partial revert of 13c663f666ac28d7a72cbe644d393fc8d2dd9881 Don't re-use free pages so soon; that leaves us vulnerable to DB corruption if data syncs successfully but meta doesn't. --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 3b0b66fa19..fe89a7a45a 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -1220,7 +1220,11 @@ mdb_page_alloc(MDB_cursor *mc, int num) pgno_t pgno = P_INVALID; MDB_ID2 mid; - if (txn->mt_txnid > 2) { + /* The free list won't have any content at all until txn 2 has + * committed. The pages from txn 1 will be free after txn 3 has + * committed. It will be safe to re-use them during txn 4. + */ + if (txn->mt_txnid > 3) { if (!txn->mt_env->me_pghead && txn->mt_dbs[FREE_DBI].md_root != P_INVALID) { @@ -1253,7 +1257,7 @@ again: { unsigned int i; - oldest = txn->mt_txnid - 1; + oldest = txn->mt_txnid - 2; for (i=0; imt_env->me_txns->mti_numreaders; i++) { txnid_t mr = txn->mt_env->me_txns->mti_readers[i].mr_txnid; if (mr && mr < oldest)