From 684847db39b512ebf45c96cb0b7bd787f40c8b8f Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 25 Jul 2017 19:08:25 +0300 Subject: [PATCH] mdbx: relax backlog estimation/preparation for freelist_save(). Change-Id: I931b76179855c16cb8b6265db262309061ac196d --- src/mdbx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 3445d67f..5b5b3b52 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -2928,7 +2928,7 @@ static __inline int mdbx_backlog_size(MDBX_txn *txn) { int reclaimed = txn->mt_env->me_reclaimed_pglist ? txn->mt_env->me_reclaimed_pglist[0] : 0; - return reclaimed + txn->mt_loose_count; + return reclaimed + txn->mt_loose_count + txn->mt_end_pgno - txn->mt_next_pgno; } /* LY: Prepare a backlog of pages to modify FreeDB itself, @@ -2943,7 +2943,8 @@ static int mdbx_prep_backlog(MDBX_txn *txn, MDBX_cursor *mc) { if (unlikely(rc)) return rc; - while (unlikely(mdbx_backlog_size(txn) < extra)) { + int backlog; + while (unlikely((backlog = mdbx_backlog_size(txn)) < extra)) { rc = mdbx_page_alloc(mc, 1, NULL, MDBX_ALLOC_GC); if (unlikely(rc)) { if (unlikely(rc != MDBX_NOTFOUND))