mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-08 06:38:21 +08:00
mdbx: extra backlog's page for MDB_LIFORECLAIM.
Change-Id: I24d656de96a4bc3a3d4f6409db75868b818a4233
This commit is contained in:
parent
7ae6c0f768
commit
745bdd346a
17
mdb.c
17
mdb.c
@ -3279,7 +3279,7 @@ static MDB_INLINE int
|
|||||||
mdb_backlog_size(MDB_txn *txn)
|
mdb_backlog_size(MDB_txn *txn)
|
||||||
{
|
{
|
||||||
int reclaimed = txn->mt_env->me_pghead ? txn->mt_env->me_pghead[0] : 0;
|
int reclaimed = txn->mt_env->me_pghead ? txn->mt_env->me_pghead[0] : 0;
|
||||||
return reclaimed += txn->mt_loose_count;
|
return reclaimed + txn->mt_loose_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LY: Prepare a backlog of pages to modify FreeDB itself,
|
/* LY: Prepare a backlog of pages to modify FreeDB itself,
|
||||||
@ -3288,16 +3288,21 @@ mdb_backlog_size(MDB_txn *txn)
|
|||||||
static int
|
static int
|
||||||
mdb_prep_backlog(MDB_txn *txn, MDB_cursor *mc)
|
mdb_prep_backlog(MDB_txn *txn, MDB_cursor *mc)
|
||||||
{
|
{
|
||||||
if (mdb_backlog_size(txn) <= mc->mc_db->md_depth) {
|
/* LY: extra page(s) for b-tree rebalancing */
|
||||||
|
const int extra = (txn->mt_env->me_flags & MDB_LIFORECLAIM) ? 2 : 1;
|
||||||
|
|
||||||
|
if (mdb_backlog_size(txn) < mc->mc_db->md_depth + extra) {
|
||||||
int rc = mdb_cursor_touch(mc);
|
int rc = mdb_cursor_touch(mc);
|
||||||
if (unlikely(rc))
|
if (unlikely(rc))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* LY: one more page is required if a b-tree needs rebalancing */
|
while (unlikely(mdb_backlog_size(txn) < extra)) {
|
||||||
if (unlikely(mdb_backlog_size(txn) < 1)) {
|
|
||||||
rc = mdb_page_alloc(mc, 1, NULL, MDB_ALLOC_GC);
|
rc = mdb_page_alloc(mc, 1, NULL, MDB_ALLOC_GC);
|
||||||
if (unlikely(rc && rc != MDB_NOTFOUND))
|
if (unlikely(rc)) {
|
||||||
return rc;
|
if (unlikely(rc != MDB_NOTFOUND))
|
||||||
|
return rc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user