From b0d449565da4db16d39ac8310da4ce396bab21c2 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 5 Mar 2021 01:27:40 +0300 Subject: [PATCH] mdbx: shrink dbi table immediately in the `mdbx_dbi_close_locked()`. Change-Id: Idaa5ec9791b5ffa4305e7f9f7a625fba5f956dd9 --- src/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 6cb0c1fa..c715bdbe 100644 --- a/src/core.c +++ b/src/core.c @@ -18809,8 +18809,13 @@ static int mdbx_dbi_close_locked(MDBX_env *env, MDBX_dbi dbi) { env->me_dbxs[dbi].md_name.iov_base = NULL; mdbx_free(ptr); - if (env->me_numdbs == dbi + 1) - env->me_numdbs = dbi; + if (env->me_numdbs == dbi + 1) { + unsigned i = env->me_numdbs; + do + --i; + while (i > CORE_DBS && !env->me_dbxs[i - 1].md_name.iov_base); + env->me_numdbs = i; + } return MDBX_SUCCESS; }