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.
This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2025-08-29 13:18:10 +03:00
parent 58dc772a27
commit c97a31b47b

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