mdbx: fix mdbx_override_meta() to avoid false-positive assertions.

Fixed https://github.com/erthink/libmdbx/issues/253.
This commit is contained in:
Leonid Yuriev 2021-12-13 13:03:49 +03:00
parent 29eb4c2bed
commit c70d2d62d1
2 changed files with 7 additions and 9 deletions

View File

@ -23,6 +23,7 @@ ChangeLog
Acknowledgements:
- [gcxfd <i@rmw.link>](https://github.com/gcxfd) for reporting, contributing and testing.
- [장세연 (Чан Се Ен)](https://github.com/sasgas) for reporting and testing.
New features, extensions and improvements:
@ -43,6 +44,7 @@ Minors:
- [Fixed](https://github.com/erthink/libmdbx/issues/248) extra assertion inside `mdbx_cursor_put()` for `MDBX_DUPFIXED` cases.
- Avoiding extra looping inside `mdbx_env_info_ex()`.
- Explicitly enabled core dumps from stochastic tests scripts on Linux.
- [Fixed](https://github.com/erthink/libmdbx/issues/253) `mdbx_override_meta()` to avoid false-positive assertions.
## v0.11.2 at 2021-12-02

View File

@ -12319,16 +12319,12 @@ __cold static int __must_check_result mdbx_override_meta(
MDBX_SYNC_DATA | MDBX_SYNC_IODQ);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
MDBX_meta *live = METAPAGE(env, target);
mdbx_meta_update_begin(env, live, unaligned_peek_u64(4, model->mm_txnid_a));
/* mdbx_override_meta() called only while current process have exclusive
* lock of a DB file. So meta-page could be updated directly without
* clearing consistency flag by mdbx_meta_update_begin() */
memcpy(pgno2page(env, target), page, env->me_psize);
mdbx_flush_incoherent_cpu_writeback();
mdbx_meta_update_begin(env, model,
unaligned_peek_u64(4, model->mm_txnid_a));
unaligned_poke_u64(4, model->mm_datasync_sign, MDBX_DATASIGN_WEAK);
memcpy((void *)data_page(live), page, env->me_psize);
mdbx_meta_update_end(env, live, unaligned_peek_u64(4, model->mm_txnid_b));
mdbx_flush_incoherent_cpu_writeback();
rc = mdbx_msync(&env->me_dxb_mmap, 0, pgno_align2os_bytes(env, target),
rc = mdbx_msync(&env->me_dxb_mmap, 0, pgno_align2os_bytes(env, target + 1),
MDBX_SYNC_DATA | MDBX_SYNC_IODQ);
} else {
const mdbx_filehandle_t fd = (env->me_dsync_fd != INVALID_HANDLE_VALUE)