From c97a31b47b8671cf6afc3276ffa1b742a3a65a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Fri, 29 Aug 2025 13:18:10 +0300 Subject: [PATCH] mdbx: fix inappropriate/irrelevant `MDBX_WANNA_RECOVERY` when the DB size is not rounded to sys-allocation-granularity (imported from the `stable` branch). For now this is just the patch that eliminates regression by making the least risky/invasive changes. However a complete fix involves refining the rounding of a database size, which still is to do. The check corrected by this commit was never fundamentally important, but it was added to verify the logic of rounding the database size in various cases. However, after the commit `2a7f460345edbeb26a51782cbe6af3c55254ae77` (using `fallocate()` to prevent `SIGBUS`), the behavior change led to the returning error `MDBX_WANNA_RECOVERY` in fairly harmless conditions. --- src/dxb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dxb.c b/src/dxb.c index 4136a9e4..4c846ff1 100644 --- a/src/dxb.c +++ b/src/dxb.c @@ -661,9 +661,8 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc, const mdbx_mode_t mode_bit } if (env->flags & MDBX_RDONLY) { - if (filesize_before & (globals.sys_allocation_granularity - 1)) { - ERROR("filesize should be rounded-up to system allocation granularity %u", - globals.sys_allocation_granularity); + if (filesize_before & (globals.sys_pagesize - 1)) { + ERROR("filesize should be rounded-up to system page size %u", globals.sys_pagesize); return MDBX_WANNA_RECOVERY; } WARNING("%s", "ignore filesize mismatch in readonly-mode");