Commit Graph

9 Commits

Author SHA1 Message Date
Леонид Юрьев (Leonid Yuriev)
2930b304dc mdbx: fix unexpected SIGBUS is not enough space in a filesystem (backport, squashed).
On a modern Linux the allocation of space for a file can be deferred
and/or lazy, rather than when setting its length using `ftruncate()`.
The actual allocation of space occurs when writing to the corresponding
areas of the file, or when reading ones (in this case, the file system
fills these areas with zeros).

The specific behavior depends on the type of file system and the kernel
version, but the main thing is that possibilities currently are, when
setting the file size, just the instantaneous ability to allocate space
is checked, without any booking.

If the file system is running out of space, an `ENOSPC` error may occur
when processing (inside a OS kernel) a page fault when accessing one of
the added pages after the database has been enlarged. In this case, the
OS kernel has no other alternative but to send a `SIGBUS` signal to the
process.

This commit fixes the problem by adding the use of system calls to
explicitly allocate space for a given file size.
Related-to https://github.com/erigontech/erigon/issues/16709

This is a simple improvement, however which is complicated by the need
to take into account the availability of the appropriate system API and
handle non-fatal errors from file systems that do not support the
appropriate operations. Therefore, there is a risk of regressions in
unusual/rare situations, including when hosting databases on network
media.
2025-08-24 10:30:17 +03:00
Леонид Юрьев (Leonid Yuriev)
9c1f3aa4b5 mdbx: разделение ignore_enosys() и ignore_enosys_and_eagain() (backport-required). 2025-07-20 17:05:31 +03:00
Леонид Юрьев (Leonid Yuriev)
35349cf538 mdbx: добавление опции сборки MDBX_ENABLE_NON_READONLY_EXPORT и логирование соответствующих ситуаций (backport).
Закрывает [запрос](https://gitflic.ru/project/erthink/libmdbx/issue/16).
2025-03-20 13:55:07 +03:00
Леонид Юрьев (Leonid Yuriev)
36abcc57f0 mdbx: обновление года в © (backport). 2025-01-18 10:58:31 +03:00
Леонид Юрьев (Leonid Yuriev)
e5fe279632 mdbx: логирование ошибок при открытии lck-файла. 2025-01-12 14:30:39 +03:00
Леонид Юрьев (Leonid Yuriev)
0297136648 mdbx: улучшение авто-переключения в режим without-lck при открытии БД на read-only-носителе. 2025-01-12 02:58:59 +03:00
Леонид Юрьев (Leonid Yuriev)
8867c2ddc2 mdbx: новые настройки clang-format (косметика). 2024-12-11 21:22:04 +03:00
Леонид Юрьев (Leonid Yuriev)
44865dadc7 mdbx: переименование и доработка опций сборки. 2024-12-03 00:23:37 +03:00
Леонид Юрьев (Leonid Yuriev)
3de3d425a1 mdbx: изменение лицензии и реструктуризация исходного кода. 2024-06-19 14:18:18 +03:00