From cddf9ca8a29afd9dec82e1e1f031cb0c25e59266 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 19 Dec 2019 22:52:29 +0300 Subject: [PATCH] mdbx: toggle of readers-refresh after wipe steady-point. Change-Id: I43985fb667b727a8b41dcd5c33e6012160dee16e --- src/elements/core.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/elements/core.c b/src/elements/core.c index 9a90c3da..61e4d83f 100644 --- a/src/elements/core.c +++ b/src/elements/core.c @@ -3912,21 +3912,27 @@ __cold static int mdbx_wipe_steady(MDBX_env *env, const txnid_t last_steady) { if (env->me_flags & MDBX_WRITEMAP) { mdbx_flush_incoherent_cpu_writeback(); - return mdbx_msync(&env->me_dxb_mmap, 0, pgno_align2os_bytes(env, NUM_METAS), - false); + err = mdbx_msync(&env->me_dxb_mmap, 0, pgno_align2os_bytes(env, NUM_METAS), + false); + if (unlikely(err != MDBX_SUCCESS)) + return err; + } else { +#if defined(__linux__) || defined(__gnu_linux__) + if (sync_file_range(env->me_lazy_fd, 0, pgno2bytes(env, NUM_METAS), + SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER)) + err = errno; +#else + err = mdbx_filesync(env->me_lazy_fd, MDBX_SYNC_DATA); +#endif + if (unlikely(err != MDBX_SUCCESS)) + return err; + mdbx_flush_incoherent_mmap(env->me_map, pgno2bytes(env, NUM_METAS), + env->me_os_psize); } -#if defined(__linux__) || defined(__gnu_linux__) - if (sync_file_range(env->me_lazy_fd, 0, pgno2bytes(env, NUM_METAS), - SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER)) - err = errno; -#else - err = mdbx_filesync(env->me_lazy_fd, MDBX_SYNC_DATA); -#endif - if (unlikely(err != MDBX_SUCCESS)) - return err; - mdbx_flush_incoherent_mmap(env->me_map, pgno2bytes(env, NUM_METAS), - env->me_os_psize); + if (likely(env->me_lck)) + /* force oldest refresh */ + env->me_lck->mti_readers_refresh_flag = true; return MDBX_SUCCESS; }