mdbx: fix inappropriate/irrelevant MDBX_WANNA_RECOVERY when the DB size is not rounded to sys-allocation-granularity.

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 `2930b304dc674bbccd188b7ce7c3f83755ef706e`
(using `fallocate()` to prevent `SIGBUS`), the behavior change led to
the returning error `MDBX_WANNA_RECOVERY` in fairly harmless conditions.

This fix is not perfect, but it is just a patch that eliminates
regression by making the least risky/invasive changes.

A complete fix involves refining the rounding of a database size, which
is not difficult, but it is likely to lead to a few minor unexpected
regressions. So for the `stable` branch, I preferred minimal
conservative patch.
This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2025-08-28 10:26:35 +03:00
parent 71df2ec129
commit 43cb9133ee

View File

@@ -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");