From: Howard Chu Date: Wed, 6 Mar 2013 20:30:37 +0000 (-0800) Subject: ITS#7536 fix mdb_rebalance X-Git-Tag: OPENLDAP_REL_ENG_2_4_35~26^2~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d74330128ac0c5b1ba3a06a199238f9780f685fd;p=openldap ITS#7536 fix mdb_rebalance A page must always have at least 2 keys (unless it's a root page) --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 4d8bfa3bdc..058c68b3ce 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6368,12 +6368,13 @@ mdb_rebalance(MDB_cursor *mc) DPRINTF("found neighbor page %zu (%u keys, %.1f%% full)", mn.mc_pg[mn.mc_top]->mp_pgno, NUMKEYS(mn.mc_pg[mn.mc_top]), (float)PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) / 10); - /* If the neighbor page is above threshold and has at least two - * keys, move one key from it. + /* If the neighbor page is above threshold and has at least three + * keys, move one key from it. (A page must never have fewer than + * 2 keys.) * * Otherwise we should try to merge them. */ - if (PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) >= FILL_THRESHOLD && NUMKEYS(mn.mc_pg[mn.mc_top]) >= 2) + if (PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) >= FILL_THRESHOLD && NUMKEYS(mn.mc_pg[mn.mc_top]) > 2) return mdb_node_move(&mn, mc); else { if (mc->mc_ki[ptop] == 0)