From af45cf3a04bc86d17c879e944d367661a6d34aaf Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 4 Nov 2015 20:38:30 +0000 Subject: [PATCH 1/3] ITS#8300 fix rebalance after node_move ITS#8258, ITS#7829 fixes checked parent index to see if we were moving from a left neighbor. Should have just checked to see if current index was 0, meaning we added on the left. (Parent index may not tell us anything meaningful after a nested rebalance.) --- libraries/liblmdb/mdb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 0bff10e759..37bdee9894 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8009,7 +8009,8 @@ mdb_rebalance(MDB_cursor *mc) */ if (PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) >= thresh && NUMKEYS(mn.mc_pg[mn.mc_top]) > minkeys) { rc = mdb_node_move(&mn, mc); - if (mc->mc_ki[mc->mc_top-1]) { + if (!mc->mc_ki[mc->mc_top]) { + /* if we inserted on left, bump position up */ oldki++; } } else { From 9fc7c94aeb092676b16e9849993458d6e98cb5ea Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 4 Nov 2015 21:01:30 +0000 Subject: [PATCH 2/3] ITS#8300 fix node_move Don't adjust other cursors when we added a node on the right. --- libraries/liblmdb/mdb.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 37bdee9894..56b731de56 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -7598,16 +7598,19 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst) MDB_dbi dbi = csrc->mc_dbi; MDB_page *mp; - mp = cdst->mc_pg[csrc->mc_top]; - for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { - if (csrc->mc_flags & C_SUB) - m3 = &m2->mc_xcursor->mx_cursor; - else - m3 = m2; - if (m3 == cdst) continue; - if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] >= - cdst->mc_ki[csrc->mc_top]) { - m3->mc_ki[csrc->mc_top]++; + /* If we're adding on the left, bump others up */ + if (!cdst->mc_ki[csrc->mc_top]) { + mp = cdst->mc_pg[csrc->mc_top]; + for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { + if (csrc->mc_flags & C_SUB) + m3 = &m2->mc_xcursor->mx_cursor; + else + m3 = m2; + if (m3 == cdst) continue; + if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] >= + cdst->mc_ki[csrc->mc_top]) { + m3->mc_ki[csrc->mc_top]++; + } } } From e339fced30e99a6971a949dd6f1349c70b636a6e Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 4 Nov 2015 21:03:22 +0000 Subject: [PATCH 3/3] ITS#8300 --- libraries/liblmdb/CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/liblmdb/CHANGES b/libraries/liblmdb/CHANGES index 07b087aad9..fb4b482385 100644 --- a/libraries/liblmdb/CHANGES +++ b/libraries/liblmdb/CHANGES @@ -9,6 +9,7 @@ LMDB 0.9.17 Release Engineering Fix ITS#8263 cursor_put cursor tracking Fix ITS#8264 cursor_del cursor tracking Fix ITS#8299 mdb_del cursor tracking + Fix ITS#8300 mdb_del cursor tracking Fix ITS#7771 fakepage cursor tracking Fix ITS#7789 ensure mapsize >= pages in use Fix ITS#7971 mdb_txn_renew0() new reader slots