summaryrefslogtreecommitdiff
path: root/libs/libmdbx
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-20 18:24:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-20 18:24:06 +0300
commita8d704883591202f97f0c877d036c0c877a79d66 (patch)
tree1020f4c7ab62f5449e09bacd787ef7374a1fcbb2 /libs/libmdbx
parent068a19fb0f4c2f8efa79977a3e3c8dd239ca8a33 (diff)
fixes #2268 (Update libmdbx to 0.7.0)
Diffstat (limited to 'libs/libmdbx')
-rw-r--r--libs/libmdbx/src/GNUmakefile5
-rw-r--r--libs/libmdbx/src/mdbx.h43
-rw-r--r--libs/libmdbx/src/src/CMakeLists.txt7
-rw-r--r--libs/libmdbx/src/src/elements/config.h6
-rw-r--r--libs/libmdbx/src/src/elements/core.c20
-rw-r--r--libs/libmdbx/src/src/elements/lck-posix.c9
-rw-r--r--libs/libmdbx/src/src/elements/lck-windows.c12
-rw-r--r--libs/libmdbx/src/src/elements/osal.c14
-rw-r--r--libs/libmdbx/src/src/elements/version.c6
-rw-r--r--libs/libmdbx/src/test/jitter.cc6
10 files changed, 66 insertions, 62 deletions
diff --git a/libs/libmdbx/src/GNUmakefile b/libs/libmdbx/src/GNUmakefile
index 6dff934609..5d9d25b9bf 100644
--- a/libs/libmdbx/src/GNUmakefile
+++ b/libs/libmdbx/src/GNUmakefile
@@ -236,10 +236,7 @@ dist/@tmp-shared_internals.inc: src/elements/version.c $(ALLOY_DEPS) $(lastword
dist/mdbx.c: dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
mkdir -p dist && (cat dist/@tmp-shared_internals.inc \
- && cat src/elements/core.c src/elements/osal.c src/elements/version.c \
- && echo '#if defined(_WIN32) || defined(_WIN64)' \
- && cat src/elements/lck-windows.c && echo '#else /* LCK-implementation */' \
- && cat src/elements/lck-posix.c && echo '#endif /* LCK-implementation */' \
+ && cat src/elements/core.c src/elements/osal.c src/elements/version.c src/elements/lck-windows.c src/elements/lck-posix.c \
) | grep -v -e '#include "' -e '#pragma once' | sed 's|@INCLUDE|#include|' > $@
define dist-tool-rule
diff --git a/libs/libmdbx/src/mdbx.h b/libs/libmdbx/src/mdbx.h
index 8070ce6622..971b009402 100644
--- a/libs/libmdbx/src/mdbx.h
+++ b/libs/libmdbx/src/mdbx.h
@@ -1453,9 +1453,14 @@ typedef enum MDBX_cursor_op {
/* Page has not enough space - internal error */
#define MDBX_PAGE_FULL (-30786)
-/* Database contents grew beyond environment mapsize and engine was
- * unable to extend mapping, e.g. since address space is unavailable or busy */
-#define MDBX_MAP_RESIZED (-30785)
+/* Database engine was unable to extend mapping, e.g. since address space
+ * is unavailable or busy. This can mean:
+ * - Database size extended by other process beyond to environment mapsize
+ * and engine was unable to extend mapping while starting read transaction.
+ * Environment should be reopened to continue.
+ * - Engine was unable to extend mapping during write transaction
+ * or explicit call of mdbx_env_set_geometry(). */
+#define MDBX_UNABLE_EXTEND_MAPSIZE (-30785)
/* Environment or database is not compatible with the requested operation
* or the specified flags. This can mean:
@@ -2027,9 +2032,9 @@ LIBMDBX_API int mdbx_env_get_fd(MDBX_env *env, mdbx_filehandle_t *fd);
* size. Besides, the upper bound defines the linear address space
* reservation in each process that opens the database. Therefore changing
* the upper bound is costly and may be required reopening environment in
- * case of MDBX_MAP_RESIZED errors, and so on. Therefore, this value should
- * be chosen reasonable as large as possible, to accommodate future growth
- * of the database.
+ * case of MDBX_UNABLE_EXTEND_MAPSIZE errors, and so on. Therefore, this
+ * value should be chosen reasonable as large as possible, to accommodate
+ * future growth of the database.
* - The growth step must be greater than zero to allow the database to grow,
* but also reasonable not too small, since increasing the size by little
* steps will result a large overhead.
@@ -2049,6 +2054,7 @@ LIBMDBX_API int mdbx_env_get_fd(MDBX_env *env, mdbx_filehandle_t *fd);
* - Windows does not provide the usual API to augment a memory-mapped file
* (that is, a memory-mapped partition), but only by using "Native API"
* in an undocumented way.
+ *
* MDBX bypasses all Windows issues, but at a cost:
* - Ability to resize database on the fly requires an additional lock
* and release SlimReadWriteLock during each read-only transaction.
@@ -2069,10 +2075,10 @@ LIBMDBX_API int mdbx_env_get_fd(MDBX_env *env, mdbx_filehandle_t *fd);
*
* If the mapsize is increased by another process, MDBX silently and
* transparently adopt these changes at next transaction start. However,
- * mdbx_txn_begin() will return MDBX_MAP_RESIZED if new mapping size could not
- * be applied for current process (for instance if address space is busy).
- * Therefore, in the case of MDBX_MAP_RESIZED error you need close and reopen
- * the environment to resolve error.
+ * mdbx_txn_begin() will return MDBX_UNABLE_EXTEND_MAPSIZE if new mapping size
+ * could not be applied for current process (for instance if address space
+ * is busy). Therefore, in the case of MDBX_UNABLE_EXTEND_MAPSIZE error you
+ * need close and reopen the environment to resolve error.
*
* NOTE: Actual values may be different than your have specified because of
* rounding to specified database page size, the system page size and/or the
@@ -2103,13 +2109,13 @@ LIBMDBX_API int mdbx_env_get_fd(MDBX_env *env, mdbx_filehandle_t *fd);
* database is used by other processes or threaded
* (i.e. just pass -1 in this argument except absolutely
* necessity). Otherwise you must be ready for
- * MDBX_MAP_RESIZED error(s), unexpected pauses during
- * remapping and/or system errors like "addtress busy",
- * and so on. In other words, there is no way to handle
- * a growth of the upper bound robustly because there may
- * be a lack of appropriate system resources (which are
- * extremely volatile in a multi-process multi-threaded
- * environment).
+ * MDBX_UNABLE_EXTEND_MAPSIZE error(s), unexpected pauses
+ * during remapping and/or system errors like "addtress
+ * busy", and so on. In other words, there is no way to
+ * handle a growth of the upper bound robustly because
+ * there may be a lack of appropriate system resources
+ * (which are extremely volatile in a multi-process
+ * multi-threaded environment).
*
* [in] growth_step The growth step in bytes, must be greater than zero
* to allow the database to grow.
@@ -2301,7 +2307,8 @@ LIBMDBX_API void *mdbx_env_get_userctx(MDBX_env *env);
* possible errors are:
* - MDBX_PANIC = a fatal error occurred earlier and the environment
* must be shut down.
- * - MDBX_MAP_RESIZED = another process wrote data beyond this MDBX_env's
+ * - MDBX_UNABLE_EXTEND_MAPSIZE
+ * = another process wrote data beyond this MDBX_env's
* mapsize and this environment's map must be resized
* as well. See mdbx_env_set_mapsize().
* - MDBX_READERS_FULL = a read-only transaction was requested and the reader
diff --git a/libs/libmdbx/src/src/CMakeLists.txt b/libs/libmdbx/src/src/CMakeLists.txt
index 82c953dabb..8a33ede361 100644
--- a/libs/libmdbx/src/src/CMakeLists.txt
+++ b/libs/libmdbx/src/src/CMakeLists.txt
@@ -19,14 +19,9 @@ message(STATUS "libmdbx version is ${MDBX_VERSION}")
if(MDBX_ALLOY_MODE)
set(LIBMDBX_SOURCES alloy.c)
else()
- if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- set(LIBMDBX_OSAL windows)
- else()
- set(LIBMDBX_OSAL posix)
- endif()
set(LIBMDBX_SOURCES
elements/options.h elements/defs.h elements/internals.h elements/osal.h
- elements/core.c elements/osal.c elements/lck-${LIBMDBX_OSAL}.c)
+ elements/core.c elements/osal.c elements/lck-posix.c elements/lck-windows.c)
endif()
list(APPEND LIBMDBX_SOURCES ../mdbx.h
"${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c"
diff --git a/libs/libmdbx/src/src/elements/config.h b/libs/libmdbx/src/src/elements/config.h
index 38813164bf..f05ba6fc85 100644
--- a/libs/libmdbx/src/src/elements/config.h
+++ b/libs/libmdbx/src/src/elements/config.h
@@ -45,12 +45,12 @@
#endif
/* Build Info */
-#define MDBX_BUILD_TIMESTAMP "2020-02-21T09:26:28Z"
+#define MDBX_BUILD_TIMESTAMP "2020-03-20T14:47:36Z"
#define MDBX_BUILD_TARGET "x86_64-Windows"
/* #undef MDBX_BUILD_CONFIG */
-#define MDBX_BUILD_COMPILER "MSVC-19.24.28316.0"
+#define MDBX_BUILD_COMPILER "MSVC-19.25.28610.4"
#define MDBX_BUILD_FLAGS "LIBMDBX_EXPORTS"
-#define MDBX_BUILD_SOURCERY 0e8083ca08c70e6b3897c7ce4a313edce5ac635ec38248f6d6bb18c475e1ce94_v0_6_0_38_g9bdac28
+#define MDBX_BUILD_SOURCERY b8a401ae08d0312d6e5365c29bb58adea2e44dbc7e3d808df4a0de2fefcc65ca_v0_6_0_45_gc20ba1e
/* *INDENT-ON* */
/* clang-format on */
diff --git a/libs/libmdbx/src/src/elements/core.c b/libs/libmdbx/src/src/elements/core.c
index eb86fd1448..6a5b079493 100644
--- a/libs/libmdbx/src/src/elements/core.c
+++ b/libs/libmdbx/src/src/elements/core.c
@@ -3184,12 +3184,12 @@ static const char *__mdbx_strerr(int errnum) {
"MDBX_READERS_FULL: Too many readers (maxreaders reached)",
NULL /* MDBX_TLS_FULL (-30789): unused in MDBX */,
"MDBX_TXN_FULL: Transaction has too many dirty pages,"
- " i.e transaction too big",
+ " i.e transaction is too big",
"MDBX_CURSOR_FULL: Internal error - Cursor stack limit reached",
"MDBX_PAGE_FULL: Internal error - Page has no more space",
- "MDBX_MAP_RESIZED: Database contents grew beyond environment mapsize"
- " and engine was unable to extend mapping,"
- " e.g. since address space is unavailable or busy",
+ "MDBX_UNABLE_EXTEND_MAPSIZE: Database engine was unable to extend"
+ " mapping, e.g. since address space is unavailable or busy,"
+ " or Operation system not supported such operations"
"MDBX_INCOMPATIBLE: Environment or database is not compatible"
" with the requested operation or the specified flags",
"MDBX_BAD_RSLOT: Invalid reuse of reader locktable slot,"
@@ -4762,7 +4762,7 @@ bailout:
}
#endif /* MDBX_USE_VALGRIND */
} else {
- if (rc != MDBX_RESULT_TRUE) {
+ if (rc != MDBX_UNABLE_EXTEND_MAPSIZE) {
mdbx_error("failed resize datafile/mapping: "
"present %" PRIuPTR " -> %" PRIuPTR ", "
"limit %" PRIuPTR " -> %" PRIuPTR ", errcode %d",
@@ -5250,7 +5250,7 @@ skip_cache:
rc = MDBX_NOTFOUND;
if (flags & MDBX_ALLOC_NEW) {
rc = MDBX_MAP_FULL;
- if (next <= txn->mt_geo.upper) {
+ if (next <= txn->mt_geo.upper && txn->mt_geo.grow) {
mdbx_assert(env, next > txn->mt_end_pgno);
pgno_t aligned = pgno_align2os_pgno(
env, pgno_add(next, txn->mt_geo.grow - next % txn->mt_geo.grow));
@@ -5271,7 +5271,6 @@ skip_cache:
mdbx_error("unable growth datafile to %" PRIaPGNO " pages (+%" PRIaPGNO
"), errcode %d",
aligned, aligned - txn->mt_end_pgno, rc);
- rc = (rc == MDBX_RESULT_TRUE) ? MDBX_MAP_FULL : rc;
} else {
mdbx_debug("gc-alloc: next %u > upper %u", next, txn->mt_geo.upper);
}
@@ -6051,16 +6050,13 @@ static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
if (txn->mt_geo.upper > MAX_PAGENO ||
bytes2pgno(env, pgno2bytes(env, txn->mt_geo.upper)) !=
txn->mt_geo.upper) {
- rc = MDBX_MAP_RESIZED;
+ rc = MDBX_UNABLE_EXTEND_MAPSIZE;
goto bailout;
}
rc = mdbx_mapresize(env, txn->mt_next_pgno, txn->mt_end_pgno,
txn->mt_geo.upper);
- if (rc != MDBX_SUCCESS) {
- if (rc == MDBX_RESULT_TRUE)
- rc = MDBX_MAP_RESIZED;
+ if (rc != MDBX_SUCCESS)
goto bailout;
- }
}
if (txn->mt_flags & MDBX_RDONLY) {
#if defined(_WIN32) || defined(_WIN64)
diff --git a/libs/libmdbx/src/src/elements/lck-posix.c b/libs/libmdbx/src/src/elements/lck-posix.c
index 7ef4ca4dee..3754c25393 100644
--- a/libs/libmdbx/src/src/elements/lck-posix.c
+++ b/libs/libmdbx/src/src/elements/lck-posix.c
@@ -12,6 +12,8 @@
* <http://www.OpenLDAP.org/license.html>.
*/
+#if !(defined(_WIN32) || defined(_WIN64)) /* !Windows LCK-implementation */
+
#include "internals.h"
#include <sys/sem.h>
@@ -803,3 +805,10 @@ void mdbx_txn_unlock(MDBX_env *env) {
mdbx_panic("%s() failed: err %d\n", __func__, rc);
mdbx_jitter4testing(true);
}
+
+#else
+#ifdef _MSC_VER
+#pragma warning(disable : 4206) /* nonstandard extension used: translation \
+ unit is empty */
+#endif /* _MSC_VER (warnings) */
+#endif /* !Windows LCK-implementation */
diff --git a/libs/libmdbx/src/src/elements/lck-windows.c b/libs/libmdbx/src/src/elements/lck-windows.c
index 264937d9c1..13178139ea 100644
--- a/libs/libmdbx/src/src/elements/lck-windows.c
+++ b/libs/libmdbx/src/src/elements/lck-windows.c
@@ -12,17 +12,15 @@
* <http://www.OpenLDAP.org/license.html>.
*/
-#include "internals.h"
+#if defined(_WIN32) || defined(_WIN64) /* Windows LCK-implementation */
/* PREAMBLE FOR WINDOWS:
*
* We are not concerned for performance here.
* If you are running Windows a performance could NOT be the goal.
- * Otherwise please use Linux.
- *
- * Regards,
- * LY
- */
+ * Otherwise please use Linux. */
+
+#include "internals.h"
static void mdbx_winnt_import(void);
@@ -799,3 +797,5 @@ static void mdbx_winnt_import(void) {
mdbx_srwlock_ReleaseExclusive = stub_srwlock_ReleaseExclusive;
}
}
+
+#endif /* Windows LCK-implementation */
diff --git a/libs/libmdbx/src/src/elements/osal.c b/libs/libmdbx/src/src/elements/osal.c
index 9a4afba89e..06a448cdbc 100644
--- a/libs/libmdbx/src/src/elements/osal.c
+++ b/libs/libmdbx/src/src/elements/osal.c
@@ -1407,7 +1407,7 @@ MDBX_INTERNAL_FUNC int mdbx_mresize(int flags, mdbx_mmap_t *map, size_t size,
if (!(flags & MDBX_RDONLY) && limit == map->limit && size > map->current) {
/* growth rw-section */
if (!mdbx_NtExtendSection)
- return ERROR_CALL_NOT_IMPLEMENTED /* workaround for Wine */;
+ return MDBX_UNABLE_EXTEND_MAPSIZE /* workaround for Wine */;
SectionSize.QuadPart = size;
status = mdbx_NtExtendSection(map->section, &SectionSize);
if (!NT_SUCCESS(status))
@@ -1425,7 +1425,7 @@ MDBX_INTERNAL_FUNC int mdbx_mresize(int flags, mdbx_mmap_t *map, size_t size,
status = NtAllocateVirtualMemory(GetCurrentProcess(), &BaseAddress, 0,
&RegionSize, MEM_RESERVE, PAGE_NOACCESS);
if (status == /* STATUS_CONFLICTING_ADDRESSES */ 0xC0000018)
- return MDBX_RESULT_TRUE;
+ return MDBX_UNABLE_EXTEND_MAPSIZE;
if (!NT_SUCCESS(status))
return ntstatus2errcode(status);
@@ -1543,8 +1543,8 @@ retry_mapview:;
if (map->address && (size != map->current || limit != map->limit)) {
/* try remap with previously size and limit,
- * but will return MDBX_RESULT_TRUE on success */
- rc = MDBX_RESULT_TRUE;
+ * but will return MDBX_UNABLE_EXTEND_MAPSIZE on success */
+ rc = MDBX_UNABLE_EXTEND_MAPSIZE;
size = map->current;
limit = map->limit;
goto retry_file_and_section;
@@ -1567,7 +1567,7 @@ retry_mapview:;
if (flags & MDBX_RDONLY) {
map->current = (filesize > limit) ? limit : (size_t)filesize;
if (map->current != size)
- rc = MDBX_RESULT_TRUE;
+ rc = MDBX_UNABLE_EXTEND_MAPSIZE;
} else if (filesize != size) {
rc = mdbx_ftruncate(map->fd, size);
if (rc != MDBX_SUCCESS)
@@ -1584,7 +1584,7 @@ retry_mapview:;
case EAGAIN:
case ENOMEM:
case EFAULT /* MADV_DODUMP / MADV_DONTDUMP are mixed for mmap-range */:
- rc = MDBX_RESULT_TRUE;
+ rc = MDBX_UNABLE_EXTEND_MAPSIZE;
}
return rc;
}
@@ -1603,7 +1603,7 @@ retry_mapview:;
#else /* MREMAP_MAYMOVE */
/* TODO: Perhaps here it is worth to implement suspend/resume threads
* and perform unmap/map as like for Windows. */
- rc = MDBX_RESULT_TRUE;
+ rc = MDBX_UNABLE_EXTEND_MAPSIZE;
#endif /* !MREMAP_MAYMOVE */
}
#endif
diff --git a/libs/libmdbx/src/src/elements/version.c b/libs/libmdbx/src/src/elements/version.c
index e025e48256..1d964a93a1 100644
--- a/libs/libmdbx/src/src/elements/version.c
+++ b/libs/libmdbx/src/src/elements/version.c
@@ -26,9 +26,9 @@ __dll_export
0,
6,
0,
- 1928,
- {"2020-02-21T12:24:09+03:00", "f6d01d420c4be39a034e0f88e422330aa2db06f4", "9bdac2851b64d4e2636f0568066e53115acebe03",
- "v0.6.0-38-g9bdac28"},
+ 1935,
+ {"2020-03-20T17:45:36+03:00", "e01a07c814dffd0b1433ad536da16ab95344615a", "c20ba1e84f51ca9dd10603fe461b1bcc171aa075",
+ "v0.6.0-45-gc20ba1e"},
sourcery};
__dll_export
diff --git a/libs/libmdbx/src/test/jitter.cc b/libs/libmdbx/src/test/jitter.cc
index d62d71d651..71d58699de 100644
--- a/libs/libmdbx/src/test/jitter.cc
+++ b/libs/libmdbx/src/test/jitter.cc
@@ -53,7 +53,7 @@ bool testcase_jitter::run() {
err = mdbx_env_set_geometry(
db_guard.get(), -1, -1,
coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1);
- if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE &&
+ if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE &&
err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE)
failure_perror("mdbx_env_set_geometry-1", err);
}
@@ -62,7 +62,7 @@ bool testcase_jitter::run() {
err = mdbx_env_set_geometry(
db_guard.get(), -1, -1,
!coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1);
- if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE &&
+ if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE &&
err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE)
failure_perror("mdbx_env_set_geometry-2", err);
@@ -76,7 +76,7 @@ bool testcase_jitter::run() {
jitter_delay();
err =
mdbx_env_set_geometry(db_guard.get(), -1, -1, upper_limit, -1, -1, -1);
- if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE &&
+ if (err != MDBX_SUCCESS && err != MDBX_UNABLE_EXTEND_MAPSIZE &&
err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE)
failure_perror("mdbx_env_set_geometry-3", err);