mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
lmdb: ITS#8062 - fix rebalance, also handle subcursors.
(Probably fixes the ITS, definitely fixes a bug) when collapsing the root page, fixups of other cursors was incomplete.
This commit is contained in:
parent
024c5bfb60
commit
d0b4943352
1
CHANGES
1
CHANGES
@ -4,6 +4,7 @@ LMDB 0.9.15 Release Engineering
|
||||
Fix txn init (ITS#7961,#7987)
|
||||
Fix MDB_PREV_DUP (ITS#7955,#7671)
|
||||
Fix compact of empty env (ITS#7956)
|
||||
Fix mdb_rebalance collapsing root (ITS#8062)
|
||||
Fix mdb_load with large values (ITS#8066)
|
||||
Added workaround for fdatasync bug in ext3fs
|
||||
Build
|
||||
|
18
mdb.c
18
mdb.c
@ -8442,12 +8442,12 @@ mdb_rebalance(MDB_cursor *mc)
|
||||
m3 = m2;
|
||||
if (m3 == mc || m3->mc_snum < mc->mc_snum) continue;
|
||||
if (m3->mc_pg[0] == mp) {
|
||||
m3->mc_snum--;
|
||||
m3->mc_top--;
|
||||
for (i=0; i<m3->mc_snum; i++) {
|
||||
m3->mc_pg[i] = m3->mc_pg[i+1];
|
||||
m3->mc_ki[i] = m3->mc_ki[i+1];
|
||||
}
|
||||
m3->mc_snum--;
|
||||
m3->mc_top--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8515,9 +8515,23 @@ mdb_rebalance(MDB_cursor *mc)
|
||||
if (mc->mc_ki[ptop] == 0) {
|
||||
rc = mdb_page_merge(&mn, mc);
|
||||
} else {
|
||||
MDB_cursor dummy;
|
||||
oldki += NUMKEYS(mn.mc_pg[mn.mc_top]);
|
||||
mn.mc_ki[mn.mc_top] += mc->mc_ki[mn.mc_top] + 1;
|
||||
/* We want mdb_rebalance to find mn when doing fixups */
|
||||
if (mc->mc_flags & C_SUB) {
|
||||
dummy.mc_next = mc->mc_txn->mt_cursors[mc->mc_dbi];
|
||||
mc->mc_txn->mt_cursors[mc->mc_dbi] = &dummy;
|
||||
dummy.mc_xcursor = (MDB_xcursor *)&mn;
|
||||
} else {
|
||||
mn.mc_next = mc->mc_txn->mt_cursors[mc->mc_dbi];
|
||||
mc->mc_txn->mt_cursors[mc->mc_dbi] = &mn;
|
||||
}
|
||||
rc = mdb_page_merge(mc, &mn);
|
||||
if (mc->mc_flags & C_SUB)
|
||||
mc->mc_txn->mt_cursors[mc->mc_dbi] = dummy.mc_next;
|
||||
else
|
||||
mc->mc_txn->mt_cursors[mc->mc_dbi] = mn.mc_next;
|
||||
mdb_cursor_copy(&mn, mc);
|
||||
}
|
||||
mc->mc_flags &= ~C_EOF;
|
||||
|
Loading…
x
Reference in New Issue
Block a user