mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:28:21 +08:00
mdbx: fix mdbx_gc_update() for empty list of reclaimed-pages.
Change-Id: I7386eab7e663ec8ee330705c4b202429bf9f6793
This commit is contained in:
parent
64fb9b81f3
commit
f1bb2f1ec2
39
src/mdbx.c
39
src/mdbx.c
@ -3777,19 +3777,32 @@ retry:
|
||||
txn->mt_loose_count);
|
||||
} else {
|
||||
/* Room for loose pages + temp PNL with same */
|
||||
rc = mdbx_pnl_need(&env->me_reclaimed_pglist,
|
||||
2 * txn->mt_loose_count + 2);
|
||||
if (unlikely(rc != MDBX_SUCCESS))
|
||||
goto bailout;
|
||||
MDBX_PNL loose = env->me_reclaimed_pglist +
|
||||
MDBX_PNL_ALLOCLEN(env->me_reclaimed_pglist) -
|
||||
txn->mt_loose_count - 1;
|
||||
unsigned count = 0;
|
||||
for (MDBX_page *mp = txn->mt_loose_pages; mp; mp = NEXT_LOOSE_PAGE(mp))
|
||||
loose[++count] = mp->mp_pgno;
|
||||
MDBX_PNL_SIZE(loose) = count;
|
||||
mdbx_pnl_sort(loose);
|
||||
mdbx_pnl_xmerge(env->me_reclaimed_pglist, loose);
|
||||
if (likely(env->me_reclaimed_pglist != NULL)) {
|
||||
rc = mdbx_pnl_need(&env->me_reclaimed_pglist,
|
||||
2 * txn->mt_loose_count + 2);
|
||||
if (unlikely(rc != MDBX_SUCCESS))
|
||||
goto bailout;
|
||||
MDBX_PNL loose = env->me_reclaimed_pglist +
|
||||
MDBX_PNL_ALLOCLEN(env->me_reclaimed_pglist) -
|
||||
txn->mt_loose_count - 1;
|
||||
unsigned count = 0;
|
||||
for (MDBX_page *mp = txn->mt_loose_pages; mp;
|
||||
mp = NEXT_LOOSE_PAGE(mp))
|
||||
loose[++count] = mp->mp_pgno;
|
||||
MDBX_PNL_SIZE(loose) = count;
|
||||
mdbx_pnl_sort(loose);
|
||||
mdbx_pnl_xmerge(env->me_reclaimed_pglist, loose);
|
||||
} else {
|
||||
env->me_reclaimed_pglist = mdbx_pnl_alloc(txn->mt_loose_count);
|
||||
if (unlikely(env->me_reclaimed_pglist == NULL)) {
|
||||
rc = MDBX_ENOMEM;
|
||||
goto bailout;
|
||||
}
|
||||
for (MDBX_page *mp = txn->mt_loose_pages; mp;
|
||||
mp = NEXT_LOOSE_PAGE(mp))
|
||||
mdbx_pnl_xappend(env->me_reclaimed_pglist, mp->mp_pgno);
|
||||
mdbx_pnl_sort(env->me_reclaimed_pglist);
|
||||
}
|
||||
mdbx_trace("%s: append %u loose-pages to reclaimed-pages",
|
||||
dbg_prefix_mode, txn->mt_loose_count);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user