mirror of
https://github.com/isar/libmdbx.git
synced 2025-09-06 13:42:21 +08:00
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:
@@ -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");
|
||||
|
Reference in New Issue
Block a user