From 78e354689e1a7c5cb3d84a543b8a225f718ec609 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 22 Aug 2019 22:33:18 +0300 Subject: [PATCH] mdbx: backport - don't shrink DB less largest reader inside mdbx_env_set_geometry(). Change-Id: I42a5d3a08313fb9590a6730bc0dc06c7b4f16634 --- src/mdbx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mdbx.c b/src/mdbx.c index 06594421..405a80f6 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -5270,6 +5270,10 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, need_unlock = true; } MDBX_meta *head = mdbx_meta_head(env); + if (!inside_txn) { + env->me_txn0->mt_txnid = meta_txnid(env, head, false); + mdbx_find_oldest(env->me_txn0); + } if (pagesize < 0) pagesize = env->me_psize; @@ -5289,7 +5293,8 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, if (shrink_threshold < 0) shrink_threshold = pgno2bytes(env, head->mm_geo.shrink); - const size_t usedbytes = pgno2bytes(env, head->mm_geo.next); + const size_t usedbytes = + pgno2bytes(env, mdbx_find_largest(env, head->mm_geo.next)); if ((size_t)size_upper < usedbytes) { rc = MDBX_MAP_FULL; goto bailout;