From ebc4976acb4a8c9874d851e85c3f8dd4f3ecb0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 8 Dec 2022 13:42:55 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20geo-=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=B0=20?= =?UTF-8?q?=D0=B2=20`map=5Fresize()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/core.c b/src/core.c index 0962c74c..567394da 100644 --- a/src/core.c +++ b/src/core.c @@ -6109,6 +6109,9 @@ bailout: eASSERT(env, limit_bytes == env->me_dxb_mmap.limit); eASSERT(env, size_bytes <= env->me_dxb_mmap.filesize); eASSERT(env, size_bytes == env->me_dxb_mmap.current); + /* update env-geo to avoid influences */ + env->me_dbgeo.now = env->me_dxb_mmap.current; + env->me_dbgeo.upper = env->me_dxb_mmap.limit; #ifdef MDBX_USE_VALGRIND if (prev_limit != env->me_dxb_mmap.limit || prev_map != env->me_map) { VALGRIND_DISCARD(env->me_valgrind_handle); @@ -13022,6 +13025,13 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, current_geo = &env->me_txn->mt_geo; } + /* update env-geo to avoid influences */ + env->me_dbgeo.now = pgno2bytes(env, current_geo->now); + env->me_dbgeo.lower = pgno2bytes(env, current_geo->lower); + env->me_dbgeo.upper = pgno2bytes(env, current_geo->upper); + env->me_dbgeo.grow = pgno2bytes(env, pv2pages(current_geo->grow_pv)); + env->me_dbgeo.shrink = pgno2bytes(env, pv2pages(current_geo->shrink_pv)); + MDBX_geo new_geo; new_geo.lower = bytes2pgno(env, size_lower); new_geo.now = bytes2pgno(env, size_now); @@ -13094,16 +13104,20 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, } else { meta.mm_geo = new_geo; rc = sync_locked(env, env->me_flags, &meta, &env->me_txn0->tw.troika); + if (likely(rc == MDBX_SUCCESS)) { + env->me_dbgeo.now = pgno2bytes(env, new_geo.now = meta.mm_geo.now); + env->me_dbgeo.upper = + pgno2bytes(env, new_geo.upper = meta.mm_geo.upper); + } } - - if (likely(rc == MDBX_SUCCESS)) { - /* store new geo to env to avoid influences */ - env->me_dbgeo.now = pgno2bytes(env, new_geo.now); - env->me_dbgeo.lower = pgno2bytes(env, new_geo.lower); - env->me_dbgeo.upper = pgno2bytes(env, new_geo.upper); - env->me_dbgeo.grow = pgno2bytes(env, pv2pages(new_geo.grow_pv)); - env->me_dbgeo.shrink = pgno2bytes(env, pv2pages(new_geo.shrink_pv)); - } + } + if (likely(rc == MDBX_SUCCESS)) { + /* update env-geo to avoid influences */ + eASSERT(env, env->me_dbgeo.now == pgno2bytes(env, new_geo.now)); + env->me_dbgeo.lower = pgno2bytes(env, new_geo.lower); + eASSERT(env, env->me_dbgeo.upper == pgno2bytes(env, new_geo.upper)); + env->me_dbgeo.grow = pgno2bytes(env, pv2pages(new_geo.grow_pv)); + env->me_dbgeo.shrink = pgno2bytes(env, pv2pages(new_geo.shrink_pv)); } }