mdbx: fix minor typos, etc (v0.14.1-539-g290121f9).

2026-04-07 mdbx-tools: minor fix `usage()` of `mdbx_defrag`.
2026-04-07 mdbx-doc: fix minor typos.
2026-04-05 mdbx: set by-default log-level to MDBX_LOG_NOTICE.
2026-04-05 mdbx: conditional/#ifdef fix of "even bugs".
This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2026-04-07 09:51:49 +03:00
parent c940fe890c
commit 0ca56bc924
21 changed files with 71 additions and 44 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ ChangeLog
English version [by liar Google](https://libmdbx-dqdkfa-ru.translate.goog/md__change_log.html?_x_tr_sl=ru&_x_tr_tl=en) and [by Yandex](https://translated.turbopages.org/proxy_u/ru-en.en/https/libmdbx.dqdkfa.ru/md__change_log.html).
The source code is availale on [SourceCraft](https://sourcecraft.dev/dqdkfa/libmdbx) and mirrors on [abf.io](https://abf.io/erthink/libmdbx) and [GitFlic](https://gitflic.ru/project/erthink/libmdbx).
Please use the `stable` branch or the latest release for production environment through stagging, but the `master` branch for development a derivative projects.
The source code is available on [SourceCraft](https://sourcecraft.dev/dqdkfa/libmdbx) and mirrors on [abf.io](https://abf.io/erthink/libmdbx) and [GitFlic](https://gitflic.ru/project/erthink/libmdbx).
Please use the `stable` branch or the latest release for production environment through staging, but the `master` branch for development a derivative projects.
Donations are welcome to ETH `0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A`,
BTC `bc1qzvl9uegf2ea6cwlytnanrscyv8snwsvrc0xfsu`, SOL `FTCTgbHajoLVZGr8aEFWMzx3NDMyS5wXJgfeMTmJznRi`.
Всё будет хорошо!
+1 -1
View File
@@ -336,7 +336,7 @@ mdbx_modern_example: mdbx.h ut_and_examples/example-mdbx.c++ libmdbx.$(SO_SUFFIX
MAN_SRCDIR := man1/
dist:
@echo ' Starting 2026 libmdbx is distrubuted in an amalgamated source code form.'
@echo ' Starting 2026 libmdbx is distributed in an amalgamated source code form.'
@echo ' So amalgamation is no longer required. Please update your build scripts.'
config-gnumake.h: @buildflags.tag mdbx.c $(lastword $(MAKEFILE_LIST)) LICENSE NOTICE COPYRIGHT
+2 -2
View File
@@ -23,7 +23,7 @@ _libmdbx_ is an extremely fast, compact, powerful, embedded, transactional [key-
Historically, _libmdbx_ is a deeply revised and extended descendant of the legendary [Lightning Memory-Mapped Database](https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database). _libmdbx_ inherits all benefits from _LMDB_, but resolves some issues and adds [a large set of improvements](#improvements-beyond-lmdb).
[![Чат в МАКС](https://libmdbx.dqdkfa.ru/img/MAX-24x24.png)](https://max.ru/join/dKckvyuARxp1vRK-wnPur8zYCEkbR3OUOmpPWkWxp78)|[![Telergam: Support | Discussions | News](https://img.shields.io/endpoint?color=scarlet&logo=telegram&label=Support%20%7C%20Discussions%20%7C%20News&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Flibmdbx)](https://t.me/libmdbx)
[![Чат в МАКС](https://libmdbx.dqdkfa.ru/img/MAX-24x24.png)](https://max.ru/join/dKckvyuARxp1vRK-wnPur8zYCEkbR3OUOmpPWkWxp78)|[![Telegram: Support | Discussions | News](https://img.shields.io/endpoint?color=scarlet&logo=telegram&label=Support%20%7C%20Discussions%20%7C%20News&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Flibmdbx)](https://t.me/libmdbx)
> Please refer to the online [official libmdbx documentation site](https://libmdbx.dqdkfa.ru) with [`C` API description](https://libmdbx.dqdkfa.ru/group__c__api.html) and pay attention to the [`C++` API](https://sourcecraft.dev/dqdkfa/libmdbx/blob?file=mdbx.h%2B%2B#line-num-1). Donations are welcome to ETH `0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A`,
BTC `bc1qzvl9uegf2ea6cwlytnanrscyv8snwsvrc0xfsu`, SOL `FTCTgbHajoLVZGr8aEFWMzx3NDMyS5wXJgfeMTmJznRi`.
@@ -306,7 +306,7 @@ Usage
Since December 2025 _libmdbx_ is available only in an amalgamated source code form like [SQLite](https://www.sqlite.org/amalgamation.html), without additional dependencies and internal resources needed only for development of _libmdbx_ itself. Packages support for common Linux distributions is planned in the future, since release the version `1.0`.
The source code is available on [SourceCraft](https://sourcecraft.dev/dqdkfa/libmdbx) and mirrors on [AltSpace](https://altlinux.space/DQDKFA.RU/libmdbx.git), [Github](https://github.com/erthink/libmdbx), [abf.io](https://abf.io/erthink/libmdbx) and [GitFlic](https://gitflic.ru/project/erthink/libmdbx).
Please use the `stable` branch or the latest release for production environment through stagging and the `master` branch for development a derivative projects.
Please use the `stable` branch or the latest release for production environment through staging and the `master` branch for development a derivative projects.
## Building and Testing
+1 -1
View File
@@ -1 +1 @@
{ "git_describe": "v0.14.1-535-g2ea4d615", "git_timestamp": "2026-04-04T21:15:47+03:00", "git_tree": "d11775e028ddfd5d09923796876f0595b4e62968", "git_commit": "2ea4d6158a2e61552d6fce0be86f83abc027a12f", "semver": "0.14.1.535" }
{ "git_describe": "v0.14.1-539-g290121f9", "git_timestamp": "2026-04-07T09:49:22+03:00", "git_tree": "d26cd58e9bc9f02b717754b743462931af6fe464", "git_commit": "290121f9216ecb36e69c13c54822710352479736", "semver": "0.14.1.539" }
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00),
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00),
* it is the template for libmdbx's config.h
******************************************************************************/
+1 -1
View File
@@ -24,7 +24,7 @@ mdbx_chk \- MDBX checking tool
[\c
.BI \-s \ table\fR]
[\c
.BR \-0|1|2] ]
.BR \-0 | \-1 | \-2 ]
[\c
.BR \-t ]
[\c
+1 -1
View File
@@ -87,7 +87,7 @@ Limits the amount of transactions to the given value in megabytes.
.BR \-d \ percent
Desired pages filling density in percent between 50 and 100 (100 by default).
.TP
.BR \-G \ geomentry
.BR \-G \ geometry
Override database geometry in the form of five numbers
.BR L:U:G:S:P
delimited by a colon, where:
+2 -2
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
@@ -24,7 +24,7 @@
#define xMDBX_ALLOY 1 /* alloyed build */
#define MDBX_BUILD_SOURCERY 94480678e649f2ecf667647f37b98eddb130d81cbd09a73e816a546ee5d8d320_v0_14_1_535_g2ea4d615
#define MDBX_BUILD_SOURCERY f89bd241890bb7538a797bcb2b842d3ec803d893c633c83f9b9be55c61795a86_v0_14_1_539_g290121f9
#define LIBMDBX_INTERNALS
#define MDBX_DEPRECATED
+33 -6
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
@@ -14756,6 +14756,12 @@ __hot int cursor_put(MDBX_cursor *mc, const MDBX_val *key, MDBX_val *data, unsig
if (likely(cmp > 0)) {
mc->ki[mc->top]++; /* step forward for appending */
rc = MDBX_NOTFOUND;
#ifdef MDBX_EVENBUG20260405_FIX
/* 2026-04-05: Здесь занятный эффект чётности унаследованных от LMDB багов. Исправлять один без другого
* нельзя. Однако, оба исправления увеличивают исполнимый код и накладные расходы. Поэтому решено поместить
* исправление под #ifdef до появления явной необходимости в них. */
inner_gone(mc);
#endif /* MDBX_EVENBUG20260405_FIX */
} else if (unlikely(cmp != 0)) {
/* new-key < last-key */
return MDBX_EKEYMISMATCH;
@@ -17182,7 +17188,7 @@ static void defrag_progcess(dfc_t *dfc, size_t progress_increment) {
dfc->defrag_atleast >= dfc->txn->geo.first_unallocated) {
if (dfc->defrag_enough >= dfc->txn->geo.first_unallocated) {
if (!dfc->wallclock_atleast || (now_cache = defrag_now(now_cache)) >= dfc->wallclock_atleast)
dfc->stopping_reasons |= MDBX_defrag_enough_theshold;
dfc->stopping_reasons |= MDBX_defrag_enough_threshold;
} else if (dfc->wallclock_detent && ++dfc->wallclock_trottle % 64 == 0 &&
(now_cache = defrag_now(now_cache)) >= dfc->wallclock_detent)
dfc->stopping_reasons |= MDBX_defrag_time_limit;
@@ -24043,7 +24049,7 @@ __cold static void mdbx_init(void) {
(getenv_bool("MDBX_DBG_LEGACY_MULTIOPEN", false) ? MDBX_DBG_LEGACY_MULTIOPEN : 0) |
(getenv_bool("MDBX_DBG_LEGACY_OVERLAP", false) ? MDBX_DBG_LEGACY_OVERLAP : 0) |
(getenv_bool("MDBX_DBG_DONT_UPGRADE", false) ? MDBX_DBG_DONT_UPGRADE : 0);
globals.loglevel = MDBX_LOG_FATAL;
globals.loglevel = MDBX_LOG_NOTICE;
ENSURE(osal_fastmutex_init(&globals.debug_lock) == 0);
osal_ctor();
ASSERT(globals.sys_pagesize > 0 && (globals.sys_pagesize & (globals.sys_pagesize - 1)) == 0);
@@ -32400,6 +32406,27 @@ __hot int page_touch_unmodifable(MDBX_txn *txn, MDBX_cursor *mc, const page_t *c
done:
/* Adjust cursors pointing to mp */
mc->pg[mc->top] = np;
#ifdef MDBX_EVENBUG20260405_FIX
if (is_leaf(np) && inner_pointed(mc))
/* 2026-04-05: Нашёлся занятный баг, унаследованный от LMDB -- Отсутствовало обновление вложенного dupsort-курсора.
*
* С одной стороны, отсутствие этого обновления не приводило к проблемам, так как во всех существовавших путях
* выполнения вложенный курсор затем инициализировался заново.
*
* С другой стороны, такое обновление выполняется во всех остальных случаях, при условии что он связан с
* dupsort-узлом на текущей/обновлённой странице, указывающем на sub-страницу, а не отдельное дерево. Причем во
* многих вариантах развития событий, такая корректировка блокировалась явным присвоением `mc->pg[mc->top] = np`
* выше.
*
* Однако, исправление "всё сломало", буквально из-за нарушения чётности багов.
* В пути обработки put(append), позиция основного/внешнего курсора инкрементируется для последующей append-вставки,
* но вложенный курсор при этом не сбрасывается. В результате, состояние курсорной пары становилось несогласованным.
* При обновлении в отладочных сборках срабатывал assert, а в не-отладочных в dupsort-курсор записывалась чушь.
*
* По совокупности плюсов/минусов решено добавить это пояснение и оставить исправление под #ifdef, а обнаруженную
* специфику учитывать при последующей разработке. */
cursor_inner_refresh(mc, np, mc->ki[mc->top]);
#endif /* MDBX_EVENBUG20260405_FIX */
MDBX_cursor *m2 = txn->cursors[cursor_dbi(mc)];
if (mc->flags & z_inner) {
for (; m2; m2 = m2->next) {
@@ -40254,10 +40281,10 @@ __dll_export
0,
14,
1,
535,
539,
"", /* pre-release suffix of SemVer
0.14.1.535 */
{"2026-04-04T21:15:47+03:00", "d11775e028ddfd5d09923796876f0595b4e62968", "2ea4d6158a2e61552d6fce0be86f83abc027a12f", "v0.14.1-535-g2ea4d615"},
0.14.1.539 */
{"2026-04-07T09:49:22+03:00", "d26cd58e9bc9f02b717754b743462931af6fe464", "290121f9216ecb36e69c13c54822710352479736", "v0.14.1-539-g290121f9"},
sourcery};
__dll_export
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+13 -13
View File
@@ -1,4 +1,4 @@
/** This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/** This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
\file mdbx.h
\brief The libmdbx C API header file.
@@ -1417,7 +1417,7 @@ typedef enum MDBX_env_flags {
* a steady commit-point to resume reuse pages, each time there is
* insufficient space and before increasing the size of the file on disk.
*
* In other words, with `MDBX_SAFE_NOSYNC` flag MDBX insures you from the
* In other words, with `MDBX_SAFE_NOSYNC` flag MDBX ensures you from the
* whole database corruption, at the cost increasing database size and/or
* number of disk IOPs. So, `MDBX_SAFE_NOSYNC` flag could be used with
* \ref mdbx_env_sync() as alternatively for batch committing or nested
@@ -7319,17 +7319,17 @@ LIBMDBX_API int mdbx_gc_info(MDBX_txn *txn, MDBX_gc_info_t *info, size_t bytes,
* \see mdbx_env_defrag() */
typedef enum MDBX_defrag_stopping_reasons {
MDBX_defrag_noobstacles = 0,
MDBX_defrag_step_size = 1, /**< Step transaction size limit reached */
MDBX_defrag_large_chunk = 2, /**< Preliminary movement is necessary to form
a sufficient sequence of adjacent free pages in order to
then move the revealed Large/Overflow page on a next cycle */
MDBX_defrag_discontinued = 4, /**< Discontinued by user */
MDBX_defrag_laggard_reader = 8, /**< At least one process performing a reading transaction
prevents further defragmentation */
MDBX_defrag_enough_theshold = 16, /**< The defragmentation goal set by the user has been achieved */
MDBX_defrag_time_limit = 32, /**< The specified limit on the duration of defragmentation has been reached */
MDBX_defrag_aborted = 64, /**< Aborted by user */
MDBX_defrag_error = 128 /**< An error occurred during defragmentation */
MDBX_defrag_step_size = 1, /**< Step transaction size limit reached */
MDBX_defrag_large_chunk = 2, /**< Preliminary movement is necessary to form
a sufficient sequence of adjacent free pages in order to
then move the revealed Large/Overflow page on a next cycle */
MDBX_defrag_discontinued = 4, /**< Discontinued by user */
MDBX_defrag_laggard_reader = 8, /**< At least one process performing a reading transaction
prevents further defragmentation */
MDBX_defrag_enough_threshold = 16, /**< The defragmentation goal set by the user has been achieved */
MDBX_defrag_time_limit = 32, /**< The specified limit on the duration of defragmentation has been reached */
MDBX_defrag_aborted = 64, /**< Aborted by user */
MDBX_defrag_error = 128 /**< An error occurred during defragmentation */
} MDBX_defrag_stopping_reasons_t;
DEFINE_ENUM_FLAG_OPERATORS(MDBX_defrag_stopping_reasons)
+1 -1
View File
@@ -1,4 +1,4 @@
/// This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/// This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
/// \file mdbx.h++
/// \brief The libmdbx C++ API header file.
///
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+4 -4
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
@@ -53,7 +53,7 @@ static void signal_handler(int sig) {
static char *prog;
static void usage(void) {
fprintf(stderr,
"usage: %s [-V] [-q] [-c] [-d] [-p] [-u|U] db_pathname\n"
"usage: %s [-V] [-v[v[v...]]] [-q] [-1..9] [-t seconds] [-f percent] [-r percent] [-s megabytes] [-c] [-u|U] db_pathname\n"
" -V\t\tprint version and exit\n"
" -v\t\tmore verbose, could be repeated for extra details from debug-enabled builds.\n"
" -q\t\tbe quiet.\n"
@@ -143,8 +143,8 @@ static const char *stop_reason(const MDBX_defrag_result_t *progress) {
return "aborted by user";
if (progress->stopping_reasons & MDBX_defrag_discontinued)
return "discontinued by user";
if (progress->stopping_reasons & MDBX_defrag_enough_theshold)
return "enough theshold";
if (progress->stopping_reasons & MDBX_defrag_enough_threshold)
return "enough threshold";
if (progress->stopping_reasons & MDBX_defrag_time_limit)
return "time limit reached";
if (progress->stopping_reasons & MDBX_defrag_laggard_reader)
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+1 -1
View File
@@ -1,4 +1,4 @@
/* This file is part of the libmdbx amalgamated source code (v0.14.1-535-g2ea4d615 at 2026-04-04T21:15:47+03:00).
/* This file is part of the libmdbx amalgamated source code (v0.14.1-539-g290121f9 at 2026-04-07T09:49:22+03:00).
*
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
+1 -1
View File
@@ -5,7 +5,7 @@ This set of examples will be updated, and most of the examples are also publicly
### C API
The [`example-mdbx.c`](example-mdbx.c) is the example of using the C API.
However, it is strongly recommended to use the modern [C++ API](https://libmdbx.dqdkfa.ru/group__cxx__api.html), which requires less effort
and insures against many errors related to resource leaks.
and ensures against many bugs related to resource leaks.
### Berkeley DB
If you have already used Berkeley DB, then it will be useful to make a line-by-line comparison of [`example-mdbx.c`](example-mdbx.c) and the [`sample-bdb.txt`](sample-bdb.txt) file.
+1 -1
View File
@@ -1,6 +1,6 @@
/** \file The example of using the libmdbx C API.
* However, it is strongly recommended to use the modern C++ API, which requires less effort
* and insures against many errors related to resource leaks.
* and ensures against many bugs related to resource leaks.
*
* \note If you have already used Berkeley DB,
* it will be useful to make a line-by-line comparison of this example and the sample-bdb.txt