mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 06:38:22 +08:00
mdbx: rework/fix cursor tracking inside mdbx_update_gc().
Change-Id: I2c320f63901a011992bc912938bc65084f63636b
This commit is contained in:
parent
4117c9f111
commit
82c975e174
22
src/mdbx.c
22
src/mdbx.c
@ -3807,6 +3807,9 @@ static int mdbx_update_gc(MDBX_txn *txn) {
|
|||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
|
|
||||||
|
mc.mc_next = txn->mt_cursors[FREE_DBI];
|
||||||
|
txn->mt_cursors[FREE_DBI] = &mc;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
mdbx_trace(" >> restart");
|
mdbx_trace(" >> restart");
|
||||||
mdbx_tassert(txn, mdbx_pnl_check(env->me_reclaimed_pglist, true));
|
mdbx_tassert(txn, mdbx_pnl_check(env->me_reclaimed_pglist, true));
|
||||||
@ -3853,7 +3856,7 @@ retry:
|
|||||||
mdbx_trace("%s.cleanup-reclaimed-id [%u]%" PRIaTXN, dbg_prefix_mode,
|
mdbx_trace("%s.cleanup-reclaimed-id [%u]%" PRIaTXN, dbg_prefix_mode,
|
||||||
cleaned_gc_slot, cleaned_gc_id);
|
cleaned_gc_slot, cleaned_gc_id);
|
||||||
mc.mc_flags |= C_RECLAIMING;
|
mc.mc_flags |= C_RECLAIMING;
|
||||||
WITH_CURSOR_TRACKING(mc, rc = mdbx_cursor_del(&mc, 0));
|
rc = mdbx_cursor_del(&mc, 0);
|
||||||
mc.mc_flags ^= C_RECLAIMING;
|
mc.mc_flags ^= C_RECLAIMING;
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
@ -3872,12 +3875,12 @@ retry:
|
|||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
cleaned_gc_id = head_gc_id = *(txnid_t *)key.iov_base;
|
cleaned_gc_id = head_gc_id = *(txnid_t *)key.iov_base;
|
||||||
mdbx_tassert(txn, cleaned_gc_id < *env->me_oldest);
|
|
||||||
mdbx_tassert(txn, cleaned_gc_id <= env->me_last_reclaimed);
|
mdbx_tassert(txn, cleaned_gc_id <= env->me_last_reclaimed);
|
||||||
|
mdbx_tassert(txn, cleaned_gc_id < *env->me_oldest);
|
||||||
mdbx_trace("%s.cleanup-reclaimed-id %" PRIaTXN, dbg_prefix_mode,
|
mdbx_trace("%s.cleanup-reclaimed-id %" PRIaTXN, dbg_prefix_mode,
|
||||||
cleaned_gc_id);
|
cleaned_gc_id);
|
||||||
mc.mc_flags |= C_RECLAIMING;
|
mc.mc_flags |= C_RECLAIMING;
|
||||||
WITH_CURSOR_TRACKING(mc, rc = mdbx_cursor_del(&mc, 0));
|
rc = mdbx_cursor_del(&mc, 0);
|
||||||
mc.mc_flags ^= C_RECLAIMING;
|
mc.mc_flags ^= C_RECLAIMING;
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
@ -4040,8 +4043,7 @@ retry:
|
|||||||
key.iov_base = &txn->mt_txnid;
|
key.iov_base = &txn->mt_txnid;
|
||||||
do {
|
do {
|
||||||
data.iov_len = MDBX_PNL_SIZEOF(txn->mt_befree_pages);
|
data.iov_len = MDBX_PNL_SIZEOF(txn->mt_befree_pages);
|
||||||
WITH_CURSOR_TRACKING(
|
rc = mdbx_cursor_put(&mc, &key, &data, MDBX_RESERVE);
|
||||||
mc, rc = mdbx_cursor_put(&mc, &key, &data, MDBX_RESERVE));
|
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
/* Retry if mt_befree_pages[] grew during the Put() */
|
/* Retry if mt_befree_pages[] grew during the Put() */
|
||||||
@ -4250,9 +4252,7 @@ retry:
|
|||||||
data.iov_len = (chunk + 1) * sizeof(pgno_t);
|
data.iov_len = (chunk + 1) * sizeof(pgno_t);
|
||||||
mdbx_trace("%s.reserve: %u [%u...%u] @%" PRIaTXN, dbg_prefix_mode, chunk,
|
mdbx_trace("%s.reserve: %u [%u...%u] @%" PRIaTXN, dbg_prefix_mode, chunk,
|
||||||
settled + 1, settled + chunk + 1, reservation_gc_id);
|
settled + 1, settled + chunk + 1, reservation_gc_id);
|
||||||
WITH_CURSOR_TRACKING(mc,
|
rc = mdbx_cursor_put(&mc, &key, &data, MDBX_RESERVE | MDBX_NOOVERWRITE);
|
||||||
rc = mdbx_cursor_put(&mc, &key, &data,
|
|
||||||
MDBX_RESERVE | MDBX_NOOVERWRITE));
|
|
||||||
mdbx_tassert(txn, mdbx_pnl_check(env->me_reclaimed_pglist, true));
|
mdbx_tassert(txn, mdbx_pnl_check(env->me_reclaimed_pglist, true));
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
@ -4355,9 +4355,7 @@ retry:
|
|||||||
data.iov_len = (left + 1) * sizeof(pgno_t);
|
data.iov_len = (left + 1) * sizeof(pgno_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WITH_CURSOR_TRACKING(
|
rc = mdbx_cursor_put(&mc, &key, &data, MDBX_CURRENT | MDBX_RESERVE);
|
||||||
mc,
|
|
||||||
rc = mdbx_cursor_put(&mc, &key, &data, MDBX_CURRENT | MDBX_RESERVE));
|
|
||||||
mc.mc_flags &= ~(C_RECLAIMING | C_GCFREEZE);
|
mc.mc_flags &= ~(C_RECLAIMING | C_GCFREEZE);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto bailout;
|
goto bailout;
|
||||||
@ -4427,6 +4425,8 @@ retry:
|
|||||||
cleaned_gc_slot == MDBX_PNL_SIZE(txn->mt_lifo_reclaimed));
|
cleaned_gc_slot == MDBX_PNL_SIZE(txn->mt_lifo_reclaimed));
|
||||||
|
|
||||||
bailout:
|
bailout:
|
||||||
|
txn->mt_cursors[FREE_DBI] = mc.mc_next;
|
||||||
|
|
||||||
if (txn->mt_lifo_reclaimed) {
|
if (txn->mt_lifo_reclaimed) {
|
||||||
MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) = 0;
|
MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) = 0;
|
||||||
if (txn != env->me_txn0) {
|
if (txn != env->me_txn0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user