From 137f80e17722ab52fb5577ea593f09184b0f4e02 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Wed, 12 May 2021 13:55:33 +0300 Subject: [PATCH] mdbx: refile rollback-writes inside `mdbx_setup_dxb()`. --- src/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index ded54804..469461e5 100644 --- a/src/core.c +++ b/src/core.c @@ -11672,8 +11672,13 @@ static __cold int mdbx_setup_dxb(MDBX_env *env, const int lck_rc) { MDBX_meta rollback = *head; mdbx_meta_set_txnid(env, &rollback, undo_txnid); unaligned_poke_u64(4, rollback.mm_datasync_sign, MDBX_DATASIGN_WEAK); - err = mdbx_pwrite(env->me_lazy_fd, &rollback, sizeof(MDBX_meta), + const mdbx_filehandle_t fd = (env->me_dsync_fd != INVALID_HANDLE_VALUE) + ? env->me_dsync_fd + : env->me_lazy_fd; + err = mdbx_pwrite(fd, &rollback, sizeof(MDBX_meta), (uint8_t *)head - (uint8_t *)env->me_map); + if (err == MDBX_SUCCESS && fd == env->me_lazy_fd) + err = mdbx_fsync(env->me_lazy_fd, MDBX_SYNC_DATA | MDBX_SYNC_IODQ); } if (err) { mdbx_error("error %d rollback from %" PRIaTXN ", to %" PRIaTXN