From dc31d7d1a36e59252e1f3115d8824a571bda2c76 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 26 Sep 2017 19:36:51 +0300 Subject: [PATCH] mdbx: fix shrinking below a lower-bound. Change-Id: Ia6d497e2d7c6d7ee646b23b8df944a01d96445fc --- src/mdbx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 0f92e1ae..2d175cce 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -4050,9 +4050,11 @@ static int mdbx_sync_locked(MDBX_env *env, unsigned flags, pending->mm_geo.grow ? pending->mm_geo.grow : pending->mm_geo.shrink; const pgno_t aligned = pgno_align2os_pgno( env, pending->mm_geo.next + aligner - pending->mm_geo.next % aligner); - if (pending->mm_geo.now > aligned) { - shrink = pending->mm_geo.now - aligned; - pending->mm_geo.now = aligned; + const pgno_t bottom = + (aligned > pending->mm_geo.lower) ? aligned : pending->mm_geo.lower; + if (pending->mm_geo.now > bottom) { + shrink = pending->mm_geo.now - bottom; + pending->mm_geo.now = bottom; if (mdbx_meta_txnid_stable(env, head) == pending->mm_txnid_a) mdbx_meta_set_txnid(env, pending, pending->mm_txnid_a + 1); }