From 1f301e7e6f8995dc70b5fecf1bb949a9b19bf071 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Tue, 26 May 2020 19:29:55 +0300 Subject: [PATCH] mdbx: explicit sync lck-file after re-write/re-create. Change-Id: I2fad76b1d04e4b0cd2ca08cb722bd819153f9824 --- src/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core.c b/src/core.c index 435ff436..34aa2954 100644 --- a/src/core.c +++ b/src/core.c @@ -9801,6 +9801,16 @@ static int __cold mdbx_setup_lck(MDBX_env *env, char *lck_pathname, mdbx_jitter4testing(false); lck->mti_magic_and_version = MDBX_LOCK_MAGIC; lck->mti_os_and_format = MDBX_LOCK_FORMAT; + err = mdbx_msync(&env->me_lck_mmap, 0, (size_t)size, false); + if (unlikely(err != MDBX_SUCCESS)) { + mdbx_error("initial-%s for lck-file failed", "msync"); + goto bailout; + } + err = mdbx_filesync(env->me_lck_mmap.fd, MDBX_SYNC_SIZE); + if (unlikely(err != MDBX_SUCCESS)) { + mdbx_error("initial-%s for lck-file failed", "fsync"); + goto bailout; + } } else { if (lck->mti_magic_and_version != MDBX_LOCK_MAGIC) { mdbx_error("%s", "lock region has invalid magic/version");