From: Howard Chu Date: Mon, 15 Apr 2013 06:59:54 +0000 (-0700) Subject: Fix mdb_rebalance X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~69^2~13 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0cccf79a0284b05655ea07c3f4d66cb4d6b653d8;p=openldap Fix mdb_rebalance Need to check NUMKEYS as well as fill threshold, when deciding whether to change anything. Don't let the page drop below the minimum number of keys. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 8a2875cf08..ca669f2555 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6295,6 +6295,7 @@ mdb_rebalance(MDB_cursor *mc) unsigned int ptop, minkeys; MDB_cursor mn; + minkeys = 1 + (IS_BRANCH(mc->mc_pg[mc->mc_top])); #if MDB_DEBUG { pgno_t pgno; @@ -6305,7 +6306,8 @@ mdb_rebalance(MDB_cursor *mc) } #endif - if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD) { + if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD && + NUMKEYS(mc->mc_pg[mc->mc_top] >= minkeys)) { #if MDB_DEBUG pgno_t pgno; COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);