mirror of
https://github.com/isar/libmdbx.git
synced 2025-12-15 16:42:22 +08:00
Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d47eed079e | ||
|
|
d2b15b5958 | ||
|
|
d96bc98244 | ||
|
|
c2cab7a6a8 | ||
|
|
38df3ca5ad | ||
|
|
5e4b2c9ddf | ||
|
|
d777f5bb38 | ||
|
|
e912f87b2a | ||
|
|
0cc3aa3af8 | ||
|
|
adac03729d | ||
|
|
17a14ec25f | ||
|
|
4e73cdf9c6 | ||
|
|
66c354baff | ||
|
|
76399bd643 | ||
|
|
4f2aba2d22 | ||
|
|
085a97f835 | ||
|
|
a2141ceaac | ||
|
|
9d55d06a20 | ||
|
|
e93d53ed92 | ||
|
|
8cb7c0f4fb | ||
|
|
773172cc99 | ||
|
|
937b38371f | ||
|
|
c312fead97 | ||
|
|
bfff6cfe85 | ||
|
|
86c735637e | ||
|
|
ff26d30362 | ||
|
|
79a5802ad4 | ||
|
|
0e2ca3eb51 | ||
|
|
e488604448 | ||
|
|
eaa77c91cd | ||
|
|
8ed0a5946b | ||
|
|
0cd7dfb465 | ||
|
|
f38b1dab13 | ||
|
|
74d5a42578 | ||
|
|
6ecadba69a | ||
|
|
b46e5c4ce8 | ||
|
|
96139eef48 | ||
|
|
0c3a5da3cb | ||
|
|
c456625ef2 | ||
|
|
630ef98951 | ||
|
|
7179823d56 | ||
|
|
8870d33fcd | ||
|
|
710fc95d9a | ||
|
|
93a24abbab | ||
|
|
113162b651 | ||
|
|
5babf0872e | ||
|
|
331232858a | ||
|
|
fcb8cd2145 | ||
|
|
514910621e | ||
|
|
7251f47d5b | ||
|
|
edda9515d6 | ||
|
|
4632df5661 | ||
|
|
11a5c50591 | ||
|
|
3092078709 | ||
|
|
cbb71058ca | ||
|
|
9dd15a4415 | ||
|
|
30745e0621 | ||
|
|
c9659e1aca | ||
|
|
1fed51ac0d | ||
|
|
590b225fcc | ||
|
|
2f8a429f91 | ||
|
|
64e6fa93fd | ||
|
|
ee917209fe | ||
|
|
fa0a38c1ac | ||
|
|
f936217309 | ||
|
|
fe0ec8ceca | ||
|
|
6737d304a6 | ||
|
|
fe7186d549 | ||
|
|
c81226906a | ||
|
|
699361c5d0 | ||
|
|
903bcd2466 | ||
|
|
c714ee9b55 |
@@ -11,8 +11,7 @@ jobs:
|
||||
- TESTLOG: /tmp/test.log
|
||||
steps:
|
||||
- checkout
|
||||
- run: make all
|
||||
- run: ulimit -c unlimited && make check
|
||||
- run: ulimit -c unlimited && MDBX_BUILD_OPTIONS="-DNDEBUG=1 -DMDBX_FORCE_ASSERTIONS=1" make test-ubsan
|
||||
- run:
|
||||
command: |
|
||||
mkdir -p /tmp/artifacts
|
||||
|
||||
@@ -3,4 +3,4 @@ freebsd_instance:
|
||||
|
||||
task:
|
||||
install_script: pkg install -y gmake bash git
|
||||
script: git fetch --tags --force && gmake check
|
||||
script: git fetch --tags --force && gmake MDBX_BUILD_OPTIONS="-DNDEBUG=1 -DMDBX_FORCE_ASSERTIONS=1" check
|
||||
|
||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ['https://sobe.ru/na/libmdbx', 'https://paypal.me/erthink', 'https://etherscan.io/address/0x19291d8658f762f3baceae1700c0b9466572ceab']
|
||||
custom: ['https://sobe.ru/na/libmdbx', 'https://paypal.me/erthink', 'https://www.blockchain.com/en/eth/address/0x19291d8658f762f3baceae1700c0b9466572ceab', 'https://www.blockchain.com/en/btc/address/152u2KXNWWGHQS3qiBEoQaveWyPvaSWYGC']
|
||||
|
||||
11
.github/actions/spelling/expect.txt
vendored
11
.github/actions/spelling/expect.txt
vendored
@@ -61,12 +61,14 @@ ARMEL
|
||||
ARMT
|
||||
Artem
|
||||
asan
|
||||
Ashikhmin
|
||||
asis
|
||||
asm
|
||||
asprintf
|
||||
aspx
|
||||
assection
|
||||
AstraLinux
|
||||
astralinux
|
||||
atal
|
||||
atexit
|
||||
atfork
|
||||
@@ -98,6 +100,7 @@ bfin
|
||||
biarch
|
||||
bibtex
|
||||
BIGDATA
|
||||
bigdata
|
||||
bindir
|
||||
binfmt
|
||||
binutils
|
||||
@@ -599,6 +602,7 @@ github
|
||||
githubusercontent
|
||||
gitignore
|
||||
glibc
|
||||
GLIBCXX
|
||||
globals
|
||||
gmail
|
||||
gmake
|
||||
@@ -708,6 +712,7 @@ inprocess
|
||||
INSTEADOF
|
||||
integerdup
|
||||
integerkey
|
||||
interoperability
|
||||
interprocedural
|
||||
intlimits
|
||||
intptr
|
||||
@@ -977,6 +982,7 @@ microsoft
|
||||
Mikkelson
|
||||
minflt
|
||||
MINGW
|
||||
mingw
|
||||
minimalistic
|
||||
minkeys
|
||||
minlen
|
||||
@@ -1275,6 +1281,7 @@ pmax
|
||||
pmccntr
|
||||
pmcntenset
|
||||
pmedvedev
|
||||
pmeta
|
||||
pmr
|
||||
pmuseren
|
||||
pmwkaa
|
||||
@@ -1314,6 +1321,7 @@ proba
|
||||
proces
|
||||
procfs
|
||||
progname
|
||||
programdata
|
||||
PROGRAMLISTING
|
||||
projectbrief
|
||||
projectlogo
|
||||
@@ -1402,11 +1410,13 @@ REALMEM
|
||||
REALPATH
|
||||
realtime
|
||||
Rebuffo
|
||||
rebuffo
|
||||
RECO
|
||||
redis
|
||||
reedom
|
||||
reefont
|
||||
refname
|
||||
refreshenv
|
||||
REGEX
|
||||
regexp
|
||||
reinited
|
||||
@@ -1962,6 +1972,7 @@ xsize
|
||||
yml
|
||||
Yota
|
||||
Yotta
|
||||
yperbasis
|
||||
Yq
|
||||
yuriev
|
||||
Zano
|
||||
|
||||
53
.github/workflows/MinGW.yml
vendored
53
.github/workflows/MinGW.yml
vendored
@@ -27,38 +27,39 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: fetch tags
|
||||
run: git fetch --unshallow --tags --prune --force
|
||||
- name: append PATH
|
||||
run: echo 'C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin' >> $GITHUB_PATH
|
||||
- name: update mingw64
|
||||
# wanna version >= 10.2
|
||||
run: choco upgrade mingw -y --no-progress
|
||||
run: choco upgrade mingw -y --no-progress && refreshenv
|
||||
- name: configure-dll
|
||||
run: mkdir build-dll && cd build-dll && cmake -G "MinGW Makefiles" -DMDBX_BUILD_SHARED_LIBRARY:BOOL=ON -DMDBX_INSTALL_STATIC:BOOL=OFF ..
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build-dll && cd build-dll && \
|
||||
cmake -G "MinGW Makefiles" -DMDBX_BUILD_SHARED_LIBRARY:BOOL=ON -DMDBX_INSTALL_STATIC:BOOL=OFF -DMDBX_ENABLE_TESTS:BOOL=ON ..
|
||||
- name: build-dll
|
||||
shell: bash
|
||||
run: cd build-dll && cmake --build .
|
||||
- name: test-dll
|
||||
shell: pwsh
|
||||
shell: bash
|
||||
run: |
|
||||
cd build-dll
|
||||
ls
|
||||
./mdbx_test --progress --console=no --pathname=test.db --dont-cleanup-after basic > test.log
|
||||
Get-Content test.log | Select-Object -last 42
|
||||
if ($LastExitCode -ne 0) {
|
||||
throw "Exec: $ErrorMessage"
|
||||
} else {
|
||||
./mdbx_chk -nvv test.db | Tee-Object -file chk.log | Select-Object -last 42
|
||||
}
|
||||
export "PATH=/c/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin:$PATH" && \
|
||||
cd build-dll && \
|
||||
./mdbx_test.exe --progress --console=no --pathname=test.db --dont-cleanup-after basic && \
|
||||
./mdbx_chk.exe -nvv test.db
|
||||
- name: configure-static
|
||||
run: mkdir build-static && cd build-static && cmake -G "MinGW Makefiles" -DMDBX_BUILD_SHARED_LIBRARY:BOOL=OFF -DMDBX_INSTALL_STATIC:BOOL=ON ..
|
||||
- name: build-static
|
||||
run: cd build-static && cmake --build .
|
||||
- name: test-static
|
||||
shell: pwsh
|
||||
shell: bash
|
||||
run: |
|
||||
cd build-static
|
||||
ls
|
||||
./mdbx_test --progress --console=no --pathname=test.db --dont-cleanup-after basic > test.log
|
||||
Get-Content test.log | Select-Object -last 42
|
||||
if ($LastExitCode -ne 0) {
|
||||
throw "Exec: $ErrorMessage"
|
||||
} else {
|
||||
./mdbx_chk -nvv test.db | Tee-Object -file chk.log | Select-Object -last 42
|
||||
}
|
||||
mkdir build-static && cd build-static && \
|
||||
cmake -G "MinGW Makefiles" -DMDBX_BUILD_SHARED_LIBRARY:BOOL=OFF -DMDBX_INSTALL_STATIC:BOOL=ON -DMDBX_ENABLE_TESTS:BOOL=ON ..
|
||||
- name: build-static
|
||||
shell: bash
|
||||
run: |
|
||||
cd build-static && cmake --build .
|
||||
- name: test-static
|
||||
shell: bash
|
||||
run: |
|
||||
export "PATH=/c/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin:$PATH" && \
|
||||
cd build-static && \
|
||||
./mdbx_test.exe --progress --console=no --pathname=test.db --dont-cleanup-after basic && \
|
||||
./mdbx_chk.exe -nvv test.db
|
||||
|
||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -27,11 +27,11 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
#, windows-latest
|
||||
os: [ubuntu-latest, macos-latest, ubuntu-16.04]
|
||||
os: [ubuntu-latest, macos-latest, ubuntu-18.04]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: fetch tags
|
||||
run: git fetch --unshallow --tags --prune --force
|
||||
- name: make check
|
||||
run: make --keep-going all && MALLOC_CHECK_=7 MALLOC_PERTURB_=42 make --keep-going check
|
||||
run: make MDBX_BUILD_OPTIONS="-DNDEBUG=1 -DMDBX_FORCE_ASSERTIONS=1" --keep-going all && MALLOC_CHECK_=7 MALLOC_PERTURB_=42 make MDBX_BUILD_OPTIONS="-DNDEBUG=1 -DMDBX_FORCE_ASSERTIONS=1" --keep-going check
|
||||
shell: bash
|
||||
|
||||
3
AUTHORS
3
AUTHORS
@@ -2,6 +2,7 @@ Contributors
|
||||
============
|
||||
|
||||
- Alexey Naumov <alexey.naumov@gmail.com>
|
||||
- Andrew Ashikhmin <andrey.ashikhmin@gmail.com>
|
||||
- Chris Mikkelson <cmikk@qwest.net>
|
||||
- Claude Brisson <claude.brisson@gmail.com>
|
||||
- David Barbour <dmbarbour@gmail.com>
|
||||
@@ -16,7 +17,7 @@ Contributors
|
||||
- John Hewson <john@jahewson.com>
|
||||
- Klaus Malorny <klaus.malorny@knipp.de>
|
||||
- Kurt Zeilenga <kurt.zeilenga@isode.com>
|
||||
- Leonid Yuriev <leo@yuriev.ru>, <lyuryev@ptsecurity.com>
|
||||
- Leonid Yuriev <leo@yuriev.ru>, <lyuryev@ptsecurity.ru>
|
||||
- Lorenz Bauer <lmb@cloudflare.com>
|
||||
- Luke Yeager <lyeager@nvidia.com>
|
||||
- Martin Hedenfalk <martin@bzero.se>
|
||||
|
||||
@@ -93,6 +93,10 @@ else()
|
||||
endif()
|
||||
|
||||
if(DEFINED PROJECT_NAME)
|
||||
option(MDBX_FORCE_BUILD_AS_MAIN_PROJECT "Force libmdbx to full control build options even it added as a subdirectory to your project." OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED PROJECT_NAME AND NOT MDBX_FORCE_BUILD_AS_MAIN_PROJECT)
|
||||
set(SUBPROJECT ON)
|
||||
set(NOT_SUBPROJECT OFF)
|
||||
if(NOT MDBX_AMALGAMATED_SOURCE AND NOT DEFINED BUILD_TESTING)
|
||||
@@ -294,11 +298,11 @@ else()
|
||||
|
||||
if(UNIX)
|
||||
find_program(CLANG_FORMAT
|
||||
NAMES clang-format-12 clang-format-11 clang-format-10 clang-format)
|
||||
NAMES clang-format-13 clang-format)
|
||||
if(CLANG_FORMAT)
|
||||
execute_process(COMMAND ${CLANG_FORMAT} "--version" OUTPUT_VARIABLE clang_format_version_info)
|
||||
string(REGEX MATCH "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" clang_format_version_info CLANG_FORMAT_VERSION)
|
||||
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 10.0)
|
||||
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 13.0)
|
||||
# Enable 'make reformat' target.
|
||||
add_custom_target(reformat
|
||||
VERBATIM
|
||||
@@ -334,9 +338,16 @@ list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
|
||||
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
|
||||
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 HAS_CXX17)
|
||||
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_20 HAS_CXX20)
|
||||
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_23 HAS_CXX23)
|
||||
if(NOT DEFINED MDBX_CXX_STANDARD)
|
||||
if(DEFINED ENV{CMAKE_CXX_STANDARD})
|
||||
set(CMAKE_CXX_STANDARD $ENV{CMAKE_CXX_STANDARD})
|
||||
endif()
|
||||
if(DEFINED CMAKE_CXX_STANDARD)
|
||||
set(MDBX_CXX_STANDARD ${CMAKE_CXX_STANDARD})
|
||||
elseif(NOT HAS_CXX23 LESS 0
|
||||
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12))
|
||||
set(MDBX_CXX_STANDARD 23)
|
||||
elseif(NOT HAS_CXX20 LESS 0
|
||||
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9))
|
||||
set(MDBX_CXX_STANDARD 20)
|
||||
|
||||
95
ChangeLog.md
95
ChangeLog.md
@@ -1,8 +1,6 @@
|
||||
ChangeLog
|
||||
---------
|
||||
|
||||
## v0.11.x (in development)
|
||||
|
||||
### TODO
|
||||
|
||||
- [Engage an "overlapped I/O" on Windows](https://github.com/erthink/libmdbx/issues/224).
|
||||
@@ -16,10 +14,101 @@ ChangeLog
|
||||
- [Support for RAW devices](https://github.com/erthink/libmdbx/issues/124).
|
||||
- [Support MessagePack for Keys & Values](https://github.com/erthink/libmdbx/issues/115).
|
||||
- [Engage new terminology](https://github.com/erthink/libmdbx/issues/137).
|
||||
- Finalize C++ API (few typos and bugs are still maybe for now).
|
||||
- Finalize C++ API (there is still a small chance for a few typos and bugs).
|
||||
- Packages for [Astra Linux](https://astralinux.ru/), [ALT Linux](https://www.altlinux.org/), [ROSA Linux](https://www.rosalinux.ru/), etc.
|
||||
|
||||
|
||||
## v0.11.2 at 2021-12-02
|
||||
|
||||
Acknowledgements:
|
||||
|
||||
- [장세연 (Чан Се Ен)](https://github.com/sasgas) for contributing to C++ API.
|
||||
- [Alain Picard](https://github.com/castortech) for [Java bindings](https://github.com/castortech/mdbxjni).
|
||||
- [Alex Sharov](https://github.com/AskAlexSharov) for reporting and testing.
|
||||
- [Kris Zyp](https://github.com/kriszyp) for reporting and testing.
|
||||
- [Artem Vorotnikov](https://github.com/vorot93) for support [Rust wrapper](https://github.com/vorot93/libmdbx-rs).
|
||||
|
||||
Fixes:
|
||||
|
||||
- [Fixed compilation](https://github.com/erthink/libmdbx/pull/239) with `devtoolset-9` on CentOS/RHEL 7.
|
||||
- [Fixed unexpected `MDBX_PROBLEM` error](https://github.com/erthink/libmdbx/issues/242) because of update an obsolete meta-page.
|
||||
- [Fixed returning `MDBX_NOTFOUND` error](https://github.com/erthink/libmdbx/issues/243) in case an inexact value found for `MDBX_GET_BOTH` operation.
|
||||
- [Fixed compilation](https://github.com/erthink/libmdbx/issues/245) without kernel/libc-devel headers.
|
||||
|
||||
Minors:
|
||||
|
||||
- Fixed `constexpr`-related macros for legacy compilers.
|
||||
- Allowed to define 'CMAKE_CXX_STANDARD` using an environment variable.
|
||||
- Simplified collection statistics of page operation .
|
||||
- Added `MDBX_FORCE_BUILD_AS_MAIN_PROJECT` cmake option.
|
||||
- Remove unneeded `#undef P_DIRTY`.
|
||||
|
||||
|
||||
## v0.11.1 at 2021-10-23
|
||||
|
||||
### Backward compatibility break:
|
||||
|
||||
The database format signature has been changed to prevent
|
||||
forward-interoperability with an previous releases, which may lead to a
|
||||
[false positive diagnosis of database corruption](https://github.com/erthink/libmdbx/issues/238)
|
||||
due to flaws of an old library versions.
|
||||
|
||||
This change is mostly invisible:
|
||||
|
||||
- previously versions are unable to read/write a new DBs;
|
||||
- but the new release is able to handle an old DBs and will silently upgrade ones.
|
||||
|
||||
Acknowledgements:
|
||||
|
||||
- [Alex Sharov](https://github.com/AskAlexSharov) for reporting and testing.
|
||||
|
||||
|
||||
## v0.10.5 at 2021-10-13 (obsolete, please use v0.11.1)
|
||||
|
||||
Unfortunately, the `v0.10.5` accidentally comes not full-compatible with previous releases:
|
||||
|
||||
- `v0.10.5` can read/processing DBs created by previous releases, i.e. the backward-compatibility is provided;
|
||||
- however, previous releases may lead to false-corrupted state with DB that was touched by `v0.10.5`, i.e. the forward-compatibility is broken for `v0.10.4` and earlier.
|
||||
|
||||
This cannot be fixed, as it requires fixing past versions, which as a result we will just get a current version.
|
||||
Therefore, it is recommended to use `v0.11.1` instead of `v0.10.5`.
|
||||
|
||||
Acknowledgements:
|
||||
|
||||
- [Noel Kuntze](https://github.com/Thermi) for immediately bug reporting.
|
||||
|
||||
Fixes:
|
||||
|
||||
- Fixed unaligned access regression after the `#pragma pack` fix for modern compilers.
|
||||
- Added UBSAN-test to CI to avoid a regression(s) similar to lately fixed.
|
||||
- Fixed possibility of meta-pages clashing after manually turn to a particular meta-page using `mdbx_chk` utility.
|
||||
|
||||
Minors:
|
||||
|
||||
- Refined handling of weak or invalid meta-pages while a DB opening.
|
||||
- Refined providing information for the @MAIN and @GC sub-databases of a last committed modification transaction's ID.
|
||||
|
||||
|
||||
## v0.10.4 at 2021-10-10
|
||||
|
||||
Acknowledgements:
|
||||
|
||||
- [Artem Vorotnikov](https://github.com/vorot93) for support [Rust wrapper](https://github.com/vorot93/libmdbx-rs).
|
||||
- [Andrew Ashikhmin](https://github.com/yperbasis) for contributing to C++ API.
|
||||
|
||||
Fixes:
|
||||
|
||||
- Fixed possibility of looping update GC during transaction commit (no public issue since the problem was discovered inside [Positive Technologies](https://www.ptsecurity.ru)).
|
||||
- Fixed `#pragma pack` to avoid provoking some compilers to generate code with [unaligned access](https://github.com/erthink/libmdbx/issues/235).
|
||||
- Fixed `noexcept` for potentially throwing `txn::put()` of C++ API.
|
||||
|
||||
Minors:
|
||||
|
||||
- Added stochastic test script for checking small transactions cases.
|
||||
- Removed extra transaction commit/restart inside test framework.
|
||||
- In debugging builds fixed a too small (single page) by default DB shrink threshold.
|
||||
|
||||
|
||||
## v0.10.3 at 2021-08-27
|
||||
|
||||
Acknowledgements:
|
||||
|
||||
@@ -35,7 +35,7 @@ CFLAGS ?= -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-section
|
||||
# -Wno-tautological-compare
|
||||
CXX ?= g++
|
||||
# Choosing C++ standard with deferred simple variable expansion trick
|
||||
CXXSTD ?= $(eval CXXSTD := $$(shell PROBE=$$$$([ -f mdbx.c++ ] && echo mdbx.c++ || echo src/mdbx.c++); for std in gnu++20 c++20 gnu++2a c++2a gnu++17 c++17 gnu++14 c++14 gnu+11 c++11; do $(CXX) -std=$$$${std} -c $$$${PROBE} -o /dev/null 2>/dev/null >/dev/null && echo "-std=$$$${std}" && exit; done))$(CXXSTD)
|
||||
CXXSTD ?= $(eval CXXSTD := $$(shell PROBE=$$$$([ -f mdbx.c++ ] && echo mdbx.c++ || echo src/mdbx.c++); for std in gnu++23 c++23 gnu++2b c++2b gnu++20 c++20 gnu++2a c++2a gnu++17 c++17 gnu++1z c++1z gnu++14 c++14 gnu++1y c++1y gnu+11 c++11 gnu++0x c++0x; do $(CXX) -std=$$$${std} -c $$$${PROBE} -o /dev/null 2>std-$$$${std}.err >/dev/null && echo "-std=$$$${std}" && exit; done))$(CXXSTD)
|
||||
CXXFLAGS = $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS))
|
||||
|
||||
# TIP: Try append '--no-as-needed,-lrt' for ability to built with modern glibc, but then use with the old.
|
||||
|
||||
@@ -566,14 +566,14 @@ Bindings
|
||||
| ------- | ------ | ------ |
|
||||
| Haskell | [libmdbx-hs](https://hackage.haskell.org/package/libmdbx) | [Francisco Vallarino](https://github.com/fjvallarino) |
|
||||
| Python (draft) | [python-bindings](https://github.com/erthink/libmdbx/commits/python-bindings) branch | [Noel Kuntze](https://github.com/Thermi)
|
||||
| NodeJS | [lmdbx-store](https://github.com/kriszyp/lmdbx-store) | [Kris Zyp](https://github.com/kriszyp/)
|
||||
| NodeJS | [lmdbx-js](https://github.com/kriszyp/lmdbx-js) | [Kris Zyp](https://github.com/kriszyp/)
|
||||
| NodeJS | [node-mdbx](https://www.npmjs.com/package/node-mdbx/) | [Сергей Федотов](mailto:sergey.fedotov@corp.mail.ru) |
|
||||
| Ruby | [ruby-mdbx](https://rubygems.org/gems/mdbx/) | [Mahlon E. Smith](https://github.com/mahlonsmith) |
|
||||
| Go | [mdbx-go](https://github.com/torquem-ch/mdbx-go) | [Alex Sharov](https://github.com/AskAlexSharov) |
|
||||
| [Nim](https://en.wikipedia.org/wiki/Nim_(programming_language)) | [NimDBX](https://github.com/snej/nimdbx) | [Jens Alfke](https://github.com/snej)
|
||||
| Rust | [heed](https://github.com/Kerollmops/heed), [mdbx-rs](https://github.com/Kerollmops/mdbx-rs) | [Clément Renault](https://github.com/Kerollmops) |
|
||||
| Java | [mdbxjni](https://github.com/castortech/mdbxjni) | [Castor Technologies](https://castortech.com/) |
|
||||
| .NET | [mdbx.NET](https://github.com/wangjia184/mdbx.NET) | [Jerry Wang](https://github.com/wangjia184) |
|
||||
| Rust | [libmdbx-rs](https://github.com/vorot93/libmdbx-rs) | [Artem Vorotnikov](https://github.com/vorot93) |
|
||||
| Java | [mdbxjni](https://github.com/castortech/mdbxjni) | [Castor Technologies](https://castortech.com/) |
|
||||
| .NET (obsolete) | [mdbx.NET](https://github.com/wangjia184/mdbx.NET) | [Jerry Wang](https://github.com/wangjia184) |
|
||||
|
||||
<!-- section-end -->
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 0.10.3.{build}
|
||||
version: 0.11.2.{build}
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
|
||||
42
mdbx.h
42
mdbx.h
@@ -393,7 +393,8 @@ typedef mode_t mdbx_mode_t;
|
||||
#define MDBX_CXX01_CONSTEXPR __inline
|
||||
#define MDBX_CXX01_CONSTEXPR_VAR const
|
||||
#elif !defined(DOXYGEN) && \
|
||||
(!defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \
|
||||
((__cplusplus < 201103L && defined(__cpp_constexpr) && \
|
||||
__cpp_constexpr < 200704L) || \
|
||||
(defined(__LCC__) && __LCC__ < 124) || \
|
||||
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
|
||||
!defined(__clang__) && !defined(__LCC__)) || \
|
||||
@@ -410,7 +411,7 @@ typedef mode_t mdbx_mode_t;
|
||||
#define MDBX_CXX11_CONSTEXPR __inline
|
||||
#define MDBX_CXX11_CONSTEXPR_VAR const
|
||||
#elif !defined(DOXYGEN) && \
|
||||
(!defined(__cpp_constexpr) || __cpp_constexpr < 201304 || \
|
||||
(!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || \
|
||||
(defined(__LCC__) && __LCC__ < 124) || \
|
||||
(defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && \
|
||||
!defined(__LCC__)) || \
|
||||
@@ -568,9 +569,9 @@ typedef mode_t mdbx_mode_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* MDBX version 0.10.x */
|
||||
/* MDBX version 0.11.x */
|
||||
#define MDBX_VERSION_MAJOR 0
|
||||
#define MDBX_VERSION_MINOR 10
|
||||
#define MDBX_VERSION_MINOR 11
|
||||
|
||||
#ifndef LIBMDBX_API
|
||||
#if defined(LIBMDBX_EXPORTS)
|
||||
@@ -1382,10 +1383,10 @@ DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags_t)
|
||||
enum MDBX_db_flags_t {
|
||||
MDBX_DB_DEFAULTS = 0,
|
||||
|
||||
/** Use reverse string keys */
|
||||
/** Use reverse string comparison for keys. */
|
||||
MDBX_REVERSEKEY = UINT32_C(0x02),
|
||||
|
||||
/** Use sorted duplicates, i.e. allow multi-values */
|
||||
/** Use sorted duplicates, i.e. allow multi-values for a keys. */
|
||||
MDBX_DUPSORT = UINT32_C(0x04),
|
||||
|
||||
/** Numeric keys in native byte order either uint32_t or uint64_t. The keys
|
||||
@@ -1393,18 +1394,19 @@ enum MDBX_db_flags_t {
|
||||
* arguments. */
|
||||
MDBX_INTEGERKEY = UINT32_C(0x08),
|
||||
|
||||
/** With \ref MDBX_DUPSORT; sorted dup items have fixed size */
|
||||
/** With \ref MDBX_DUPSORT; sorted dup items have fixed size. The data values
|
||||
* must all be of the same size. */
|
||||
MDBX_DUPFIXED = UINT32_C(0x10),
|
||||
|
||||
/** With \ref MDBX_DUPSORT and with \ref MDBX_DUPFIXED; dups are fixed size
|
||||
* \ref MDBX_INTEGERKEY -style integers. The data values must all be of the
|
||||
* same size and must be aligned while passing as arguments. */
|
||||
* like \ref MDBX_INTEGERKEY -style integers. The data values must all be of
|
||||
* the same size and must be aligned while passing as arguments. */
|
||||
MDBX_INTEGERDUP = UINT32_C(0x20),
|
||||
|
||||
/** With \ref MDBX_DUPSORT; use reverse string comparison */
|
||||
/** With \ref MDBX_DUPSORT; use reverse string comparison for data values. */
|
||||
MDBX_REVERSEDUP = UINT32_C(0x40),
|
||||
|
||||
/** Create DB if not already existing */
|
||||
/** Create DB if not already existing. */
|
||||
MDBX_CREATE = UINT32_C(0x40000),
|
||||
|
||||
/** Opens an existing sub-database created with unknown flags.
|
||||
@@ -1735,7 +1737,7 @@ enum MDBX_error_t {
|
||||
#ifdef ENODATA
|
||||
MDBX_ENODATA = ENODATA,
|
||||
#else
|
||||
MDBX_ENODATA = -1,
|
||||
MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
|
||||
#endif /* ENODATA */
|
||||
MDBX_EINVAL = EINVAL,
|
||||
MDBX_EACCESS = EACCES,
|
||||
@@ -3284,9 +3286,11 @@ struct MDBX_commit_latency {
|
||||
uint32_t gc;
|
||||
/** \brief Duration of internal audit if enabled. */
|
||||
uint32_t audit;
|
||||
/** \brief Duration of writing dirty/modified data pages. */
|
||||
/** \brief Duration of writing dirty/modified data pages to a filesystem,
|
||||
* i.e. the summary duration of a `write()` syscalls during commit. */
|
||||
uint32_t write;
|
||||
/** \brief Duration of syncing written data to the dist/storage. */
|
||||
/** \brief Duration of syncing written data to the disk/storage, i.e.
|
||||
* the duration of a `fdatasync()` or a `msync()` syscall during commit. */
|
||||
uint32_t sync;
|
||||
/** \brief Duration of transaction ending (releasing resources). */
|
||||
uint32_t ending;
|
||||
@@ -3509,10 +3513,14 @@ LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary);
|
||||
* The reasons to not using custom comparators are:
|
||||
* - The order of records could not be validated without your code.
|
||||
* So `mdbx_chk` utility will reports "wrong order" errors
|
||||
* and the `-i` option is required to ignore ones.
|
||||
* and the `-i` option is required to suppress ones.
|
||||
* - A records could not be ordered or sorted without your code.
|
||||
* So mdbx_load utility should be used with `-a` option to preserve
|
||||
* input data order. */
|
||||
* So `mdbx_load` utility should be used with `-a` option to preserve
|
||||
* input data order.
|
||||
* - However, the custom comparators feature will never be removed.
|
||||
* You have been warned but still can use custom comparators knowing
|
||||
* about the issues noted above. In this case you should ignore `deprecated`
|
||||
* warnings or define `MDBX_DEPRECATED` macro to empty to avoid ones. */
|
||||
typedef int(MDBX_cmp_func)(const MDBX_val *a,
|
||||
const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
|
||||
|
||||
|
||||
39
mdbx.h++
39
mdbx.h++
@@ -286,7 +286,8 @@ class cursor;
|
||||
class cursor_managed;
|
||||
|
||||
#if defined(DOXYGEN) || \
|
||||
defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
|
||||
(defined(__cpp_lib_memory_resource) && \
|
||||
__cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI)
|
||||
/// \brief Default polymorphic allocator for modern code.
|
||||
using polymorphic_allocator = ::std::pmr::string::allocator_type;
|
||||
#endif /* __cpp_lib_memory_resource >= 201603L */
|
||||
@@ -476,30 +477,23 @@ static MDBX_CXX20_CONSTEXPR void *memcpy(void *dest, const void *src,
|
||||
|
||||
template <typename T>
|
||||
concept MutableByteProducer = requires(T a, char array[42]) {
|
||||
{ a.is_empty() }
|
||||
->std::same_as<bool>;
|
||||
{ a.envisage_result_length() }
|
||||
->std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) }
|
||||
->std::same_as<char *>;
|
||||
{ a.is_empty() } -> std::same_as<bool>;
|
||||
{ a.envisage_result_length() } -> std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) } -> std::same_as<char *>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept ImmutableByteProducer = requires(const T &a, char array[42]) {
|
||||
{ a.is_empty() }
|
||||
->std::same_as<bool>;
|
||||
{ a.envisage_result_length() }
|
||||
->std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) }
|
||||
->std::same_as<char *>;
|
||||
{ a.is_empty() } -> std::same_as<bool>;
|
||||
{ a.envisage_result_length() } -> std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) } -> std::same_as<char *>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept SliceTranscoder =
|
||||
ImmutableByteProducer<T> &&requires(const slice &source, const T &a) {
|
||||
concept SliceTranscoder = ImmutableByteProducer<T> &&
|
||||
requires(const slice &source, const T &a) {
|
||||
T(source);
|
||||
{ a.is_erroneous() }
|
||||
->std::same_as<bool>;
|
||||
{ a.is_erroneous() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
#endif /* __cpp_concepts >= 201907L*/
|
||||
@@ -3606,8 +3600,7 @@ public:
|
||||
|
||||
inline MDBX_error_t put(map_handle map, const slice &key, slice *value,
|
||||
MDBX_put_flags_t flags) noexcept;
|
||||
inline void put(map_handle map, const slice &key, slice value,
|
||||
put_mode mode) noexcept;
|
||||
inline void put(map_handle map, const slice &key, slice value, put_mode mode);
|
||||
inline void insert(map_handle map, const slice &key, slice value);
|
||||
inline value_result try_insert(map_handle map, const slice &key, slice value);
|
||||
inline slice insert_reserve(map_handle map, const slice &key,
|
||||
@@ -4405,9 +4398,9 @@ MDBX_CXX14_CONSTEXPR intptr_t slice::compare_fast(const slice &a,
|
||||
const slice &b) noexcept {
|
||||
const intptr_t diff = intptr_t(a.length()) - intptr_t(b.length());
|
||||
return diff ? diff
|
||||
: MDBX_UNLIKELY(a.length() == 0 || a.data() == b.data())
|
||||
? 0
|
||||
: memcmp(a.data(), b.data(), a.length());
|
||||
: MDBX_UNLIKELY(a.length() == 0 || a.data() == b.data())
|
||||
? 0
|
||||
: memcmp(a.data(), b.data(), a.length());
|
||||
}
|
||||
|
||||
MDBX_CXX14_CONSTEXPR intptr_t
|
||||
@@ -5166,7 +5159,7 @@ inline MDBX_error_t txn::put(map_handle map, const slice &key, slice *value,
|
||||
}
|
||||
|
||||
inline void txn::put(map_handle map, const slice &key, slice value,
|
||||
put_mode mode) noexcept {
|
||||
put_mode mode) {
|
||||
error::success_or_throw(put(map, key, &value, MDBX_put_flags_t(mode)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
From 0c0df833879b3f815959c8bd9b6cc27cb9d71b9e Mon Sep 17 00:00:00 2001
|
||||
From f732fc79456f3b296543ab2625d35eeef2655618 Mon Sep 17 00:00:00 2001
|
||||
From: Leonid Yuriev <leo@yuriev.ru>
|
||||
Date: Tue, 3 Aug 2021 00:55:27 +0300
|
||||
Date: Sun, 24 Oct 2021 20:13:33 +0300
|
||||
Subject: [PATCH] package/libmdbx: new package (library/database).
|
||||
|
||||
This patch adds libmdbx v0.10.2:
|
||||
This patch adds libmdbx v0.11.1:
|
||||
- libmdbx is one of the fastest compact embeddable key-value ACID database.
|
||||
- libmdbx has a specific set of properties and capabilities,
|
||||
focused on creating unique lightweight solutions.
|
||||
@@ -103,18 +103,18 @@ index 0000000000..d13f73938f
|
||||
+ !BR2_TOOLCHAIN_GCC_AT_LEAST_4_4
|
||||
diff --git a/package/libmdbx/libmdbx.hash b/package/libmdbx/libmdbx.hash
|
||||
new file mode 100644
|
||||
index 0000000000..c8a28ada34
|
||||
index 0000000000..c8b50f9ac3
|
||||
--- /dev/null
|
||||
+++ b/package/libmdbx/libmdbx.hash
|
||||
@@ -0,0 +1,5 @@
|
||||
+# Hashes from: https://github.com/erthink/libmdbx/releases/
|
||||
+sha256 745555704df76626a6612ad0c6bc6b1a66bfab98b9245b07dfb82640aa46d6fa libmdbx-amalgamated-0.10.2.tar.gz
|
||||
+sha256 f954ba8c9768914a92c2b46aac0d66bec674dbb4d7b0f01e362ea2921746ddaa libmdbx-amalgamated-0.11.1.tar.gz
|
||||
+
|
||||
+# Locally calculated
|
||||
+sha256 310fe25c858a9515fc8c8d7d1f24a67c9496f84a91e0a0e41ea9975b1371e569 LICENSE
|
||||
diff --git a/package/libmdbx/libmdbx.mk b/package/libmdbx/libmdbx.mk
|
||||
new file mode 100644
|
||||
index 0000000000..60c5148625
|
||||
index 0000000000..02d00b1a5a
|
||||
--- /dev/null
|
||||
+++ b/package/libmdbx/libmdbx.mk
|
||||
@@ -0,0 +1,42 @@
|
||||
@@ -124,7 +124,7 @@ index 0000000000..60c5148625
|
||||
+#
|
||||
+################################################################################
|
||||
+
|
||||
+LIBMDBX_VERSION = 0.10.2
|
||||
+LIBMDBX_VERSION = 0.11.1
|
||||
+LIBMDBX_SOURCE = libmdbx-amalgamated-$(LIBMDBX_VERSION).tar.gz
|
||||
+LIBMDBX_SITE = https://github.com/erthink/libmdbx/releases/download/v$(LIBMDBX_VERSION)
|
||||
+LIBMDBX_SUPPORTS_IN_SOURCE_BUILD = NO
|
||||
@@ -161,5 +161,5 @@ index 0000000000..60c5148625
|
||||
+
|
||||
+$(eval $(cmake-package))
|
||||
--
|
||||
2.32.0
|
||||
2.33.1
|
||||
|
||||
|
||||
634
src/core.c
634
src/core.c
File diff suppressed because it is too large
Load Diff
116
src/internals.h
116
src/internals.h
@@ -61,13 +61,26 @@
|
||||
* Studio 2015 Update 3). But you could remove this #error and try to continue
|
||||
* at your own risk. In such case please don't rise up an issues related ONLY to
|
||||
* old compilers.
|
||||
*
|
||||
* NOTE:
|
||||
* Unfortunately, there are several different builds of "Visual Studio" that
|
||||
* are called "Visual Studio 2015 Update 3".
|
||||
*
|
||||
* The 190024234 is used here because it is minimal version of Visual Studio
|
||||
* that was used for build and testing libmdbx in recent years. Soon this
|
||||
* value will be increased to 19.0.24241.7, since build and testing using
|
||||
* "Visual Studio 2015" will be performed only at https://ci.appveyor.com.
|
||||
*
|
||||
* Please ask Microsoft (but not us) for information about version differences
|
||||
* and how to and where you can obtain the latest "Visual Studio 2015" build
|
||||
* with all fixes.
|
||||
*/
|
||||
#error \
|
||||
"At least \"Microsoft C/C++ Compiler\" version 19.00.24234 (Visual Studio 2015 Update 3) is required."
|
||||
#endif
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||
#if _MSC_VER > 1800
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
@@ -264,8 +277,6 @@ static __always_inline memory_order mo_c11_load(enum MDBX_memory_order fence) {
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
static __inline void mdbx_jitter4testing(bool tiny);
|
||||
|
||||
MDBX_MAYBE_UNUSED static __always_inline void
|
||||
mdbx_memory_fence(enum MDBX_memory_order order, bool write) {
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
@@ -309,70 +320,6 @@ atomic_load32(const MDBX_atomic_uint32_t *p, enum MDBX_memory_order order) {
|
||||
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||
}
|
||||
|
||||
MDBX_MAYBE_UNUSED static __always_inline uint64_t
|
||||
atomic_store64(MDBX_atomic_uint64_t *p, const uint64_t value,
|
||||
enum MDBX_memory_order order) {
|
||||
STATIC_ASSERT(sizeof(MDBX_atomic_uint64_t) == 8);
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
assert(atomic_is_lock_free(MDBX_c11a_rw(uint64_t, p)));
|
||||
atomic_store_explicit(MDBX_c11a_rw(uint64_t, p), value, mo_c11_store(order));
|
||||
#else /* MDBX_HAVE_C11ATOMICS */
|
||||
if (order != mo_Relaxed)
|
||||
mdbx_compiler_barrier();
|
||||
p->weak = value;
|
||||
mdbx_memory_fence(order, true);
|
||||
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||
#else /* !MDBX_64BIT_ATOMIC */
|
||||
mdbx_compiler_barrier();
|
||||
atomic_store32(&p->low, (uint32_t)value, mo_Relaxed);
|
||||
mdbx_jitter4testing(true);
|
||||
atomic_store32(&p->high, (uint32_t)(value >> 32), order);
|
||||
mdbx_jitter4testing(true);
|
||||
#endif /* !MDBX_64BIT_ATOMIC */
|
||||
return value;
|
||||
}
|
||||
|
||||
MDBX_MAYBE_UNUSED static
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
__always_inline
|
||||
#endif /* MDBX_64BIT_ATOMIC */
|
||||
uint64_t
|
||||
atomic_load64(const MDBX_atomic_uint64_t *p,
|
||||
enum MDBX_memory_order order) {
|
||||
STATIC_ASSERT(sizeof(MDBX_atomic_uint64_t) == 8);
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
assert(atomic_is_lock_free(MDBX_c11a_ro(uint64_t, p)));
|
||||
return atomic_load_explicit(MDBX_c11a_ro(uint64_t, p), mo_c11_load(order));
|
||||
#else /* MDBX_HAVE_C11ATOMICS */
|
||||
mdbx_memory_fence(order, false);
|
||||
const uint64_t value = p->weak;
|
||||
if (order != mo_Relaxed)
|
||||
mdbx_compiler_barrier();
|
||||
return value;
|
||||
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||
#else /* !MDBX_64BIT_ATOMIC */
|
||||
mdbx_compiler_barrier();
|
||||
uint64_t value = (uint64_t)atomic_load32(&p->high, order) << 32;
|
||||
mdbx_jitter4testing(true);
|
||||
value |= atomic_load32(&p->low, (order == mo_Relaxed) ? mo_Relaxed
|
||||
: mo_AcquireRelease);
|
||||
mdbx_jitter4testing(true);
|
||||
for (;;) {
|
||||
mdbx_compiler_barrier();
|
||||
uint64_t again = (uint64_t)atomic_load32(&p->high, order) << 32;
|
||||
mdbx_jitter4testing(true);
|
||||
again |= atomic_load32(&p->low, (order == mo_Relaxed) ? mo_Relaxed
|
||||
: mo_AcquireRelease);
|
||||
mdbx_jitter4testing(true);
|
||||
if (likely(value == again))
|
||||
return value;
|
||||
value = again;
|
||||
}
|
||||
#endif /* !MDBX_64BIT_ATOMIC */
|
||||
}
|
||||
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -384,7 +331,7 @@ MDBX_MAYBE_UNUSED static
|
||||
#define MDBX_MAGIC UINT64_C(/* 56-bit prime */ 0x59659DBDEF4C11)
|
||||
|
||||
/* FROZEN: The version number for a database's datafile format. */
|
||||
#define MDBX_DATA_VERSION 2
|
||||
#define MDBX_DATA_VERSION 3
|
||||
/* The version number for a database's lockfile format. */
|
||||
#define MDBX_LOCK_VERSION 4
|
||||
|
||||
@@ -437,7 +384,7 @@ typedef uint16_t indx_t;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Core structures for database and shared memory (i.e. format definition) */
|
||||
#pragma pack(push, 1)
|
||||
#pragma pack(push, 4)
|
||||
|
||||
/* Information about a single database in the environment. */
|
||||
typedef struct MDBX_db {
|
||||
@@ -488,8 +435,6 @@ typedef struct MDBX_meta {
|
||||
MDBX_db mm_dbs[CORE_DBS]; /* first is free space, 2nd is main db */
|
||||
/* The size of pages used in this DB */
|
||||
#define mm_psize mm_dbs[FREE_DBI].md_xsize
|
||||
/* Any persistent environment flags, see mdbx_env */
|
||||
#define mm_flags mm_dbs[FREE_DBI].md_flags
|
||||
MDBX_canary mm_canary;
|
||||
|
||||
#define MDBX_DATASIGN_NONE 0u
|
||||
@@ -517,6 +462,8 @@ typedef struct MDBX_meta {
|
||||
|
||||
} MDBX_meta;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* Common header for all page types. The page type depends on mp_flags.
|
||||
*
|
||||
* P_BRANCH and P_LEAF pages have unsorted 'MDBX_node's at the end, with
|
||||
@@ -787,7 +734,11 @@ typedef struct MDBX_lockinfo {
|
||||
|
||||
#define MDBX_DATA_MAGIC \
|
||||
((MDBX_MAGIC << 8) + MDBX_PNL_ASCENDING * 64 + MDBX_DATA_VERSION)
|
||||
#define MDBX_DATA_MAGIC_DEVEL ((MDBX_MAGIC << 8) + 255)
|
||||
|
||||
#define MDBX_DATA_MAGIC_LEGACY_COMPAT \
|
||||
((MDBX_MAGIC << 8) + MDBX_PNL_ASCENDING * 64 + 2)
|
||||
|
||||
#define MDBX_DATA_MAGIC_LEGACY_DEVEL ((MDBX_MAGIC << 8) + 255)
|
||||
|
||||
#define MDBX_LOCK_MAGIC ((MDBX_MAGIC << 8) + MDBX_LOCK_VERSION)
|
||||
|
||||
@@ -1251,6 +1202,15 @@ extern uint8_t mdbx_runtime_flags;
|
||||
extern uint8_t mdbx_loglevel;
|
||||
extern MDBX_debug_func *mdbx_debug_logger;
|
||||
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_jitter4testing(bool tiny) {
|
||||
#if MDBX_DEBUG
|
||||
if (MDBX_DBG_JITTER & mdbx_runtime_flags)
|
||||
mdbx_osal_jitter(tiny);
|
||||
#else
|
||||
(void)tiny;
|
||||
#endif
|
||||
}
|
||||
|
||||
MDBX_INTERNAL_FUNC void MDBX_PRINTF_ARGS(4, 5)
|
||||
mdbx_debug_log(int level, const char *function, int line, const char *fmt,
|
||||
...) MDBX_PRINTF_ARGS(4, 5);
|
||||
@@ -1420,15 +1380,6 @@ MDBX_INTERNAL_FUNC void mdbx_rthc_global_init(void);
|
||||
MDBX_INTERNAL_FUNC void mdbx_rthc_global_dtor(void);
|
||||
MDBX_INTERNAL_FUNC void mdbx_rthc_thread_dtor(void *ptr);
|
||||
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_jitter4testing(bool tiny) {
|
||||
#if MDBX_DEBUG
|
||||
if (MDBX_DBG_JITTER & mdbx_runtime_flags)
|
||||
mdbx_osal_jitter(tiny);
|
||||
#else
|
||||
(void)tiny;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#define MDBX_IS_ERROR(rc) \
|
||||
@@ -1563,10 +1514,11 @@ typedef struct MDBX_node {
|
||||
* | 1, a > b
|
||||
* \
|
||||
*/
|
||||
#if 1
|
||||
#ifndef __e2k__
|
||||
/* LY: fast enough on most systems */
|
||||
#define CMP2INT(a, b) (((b) > (a)) ? -1 : (a) > (b))
|
||||
#else
|
||||
/* LY: more parallelable on VLIW Elbrus */
|
||||
#define CMP2INT(a, b) (((a) > (b)) - ((b) > (a)))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
// Non-inline part of the libmdbx C++ API (preliminary)
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||
|
||||
#include "../mdbx.h++"
|
||||
|
||||
@@ -992,7 +992,8 @@ bool from_base64::is_erroneous() const noexcept {
|
||||
|
||||
template class LIBMDBX_API_TYPE buffer<legacy_allocator>;
|
||||
|
||||
#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
|
||||
#if defined(__cpp_lib_memory_resource) && \
|
||||
__cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI
|
||||
template class LIBMDBX_API_TYPE buffer<polymorphic_allocator>;
|
||||
#endif /* __cpp_lib_memory_resource >= 201603L */
|
||||
|
||||
@@ -1428,7 +1429,7 @@ __cold ::std::ostream &operator<<(::std::ostream &out,
|
||||
}
|
||||
|
||||
const auto bytes = (it.bytes < 0) ? out << "-",
|
||||
size_t(-it.bytes) : size_t(it.bytes);
|
||||
size_t(-it.bytes) : size_t(it.bytes);
|
||||
struct {
|
||||
size_t one;
|
||||
const char *suffix;
|
||||
|
||||
@@ -1461,8 +1461,9 @@ MDBX_INTERNAL_FUNC int mdbx_mmap(const int flags, mdbx_mmap_t *map,
|
||||
if (!NT_SUCCESS(err))
|
||||
return ntstatus2errcode(err);
|
||||
|
||||
SIZE_T ViewSize =
|
||||
(flags & MDBX_RDONLY) ? 0 : mdbx_RunningUnderWine() ? size : limit;
|
||||
SIZE_T ViewSize = (flags & MDBX_RDONLY) ? 0
|
||||
: mdbx_RunningUnderWine() ? size
|
||||
: limit;
|
||||
err = NtMapViewOfSection(
|
||||
map->section, GetCurrentProcess(), &map->address,
|
||||
/* ZeroBits */ 0,
|
||||
|
||||
12
src/osal.h
12
src/osal.h
@@ -33,7 +33,7 @@
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||
#if !defined(_NO_CRT_STDIO_INLINE) && MDBX_BUILD_SHARED_LIBRARY && \
|
||||
!defined(xMDBX_TOOLS) && MDBX_WITHOUT_MSVC_CRT
|
||||
#define _NO_CRT_STDIO_INLINE
|
||||
@@ -114,11 +114,9 @@
|
||||
#include <mach/mach_host.h>
|
||||
#include <mach/mach_port.h>
|
||||
#include <uuid/uuid.h>
|
||||
#undef P_DIRTY
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__gnu_linux__)
|
||||
#include <linux/sysctl.h>
|
||||
#include <sched.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <sys/statfs.h>
|
||||
@@ -481,9 +479,10 @@ typedef union MDBX_srwlock {
|
||||
} MDBX_srwlock;
|
||||
#endif /* Windows */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern void mdbx_osal_jitter(bool tiny);
|
||||
#else
|
||||
#ifndef __cplusplus
|
||||
|
||||
MDBX_MAYBE_UNUSED MDBX_INTERNAL_FUNC void mdbx_osal_jitter(bool tiny);
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_jitter4testing(bool tiny);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Atomics */
|
||||
@@ -735,7 +734,6 @@ MDBX_MAYBE_UNUSED static __inline uintptr_t mdbx_thread_self(void) {
|
||||
return (uintptr_t)thunk;
|
||||
}
|
||||
|
||||
MDBX_MAYBE_UNUSED MDBX_INTERNAL_FUNC void mdbx_osal_jitter(bool tiny);
|
||||
MDBX_INTERNAL_FUNC uint64_t mdbx_osal_monotime(void);
|
||||
MDBX_INTERNAL_FUNC uint64_t
|
||||
mdbx_osal_16dot16_to_monotime(uint32_t seconds_16dot16);
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
#define _WIN32_WINNT 0x0601 /* Windows 7 */
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable : 4548) /* expression before comma has no effect; \
|
||||
expected expression with side - effect */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace chrono {
|
||||
|
||||
#pragma pack(push, 1)
|
||||
#pragma pack(push, 4)
|
||||
|
||||
typedef union time {
|
||||
uint64_t fixedpoint;
|
||||
|
||||
@@ -135,8 +135,6 @@ inline bool parse_option_intptr(int argc, char *const argv[], int &narg,
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct keygen_params_pod {
|
||||
/* Параметры генератора пар key-value. Также может быть полезным описание
|
||||
* алгоритма генерации в keygen.h
|
||||
@@ -307,8 +305,6 @@ struct actor_config_pod {
|
||||
wait4id(wait4id) {}
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
extern const struct option_verb mode_bits[];
|
||||
extern const struct option_verb table_bits[];
|
||||
void dump(const char *title = "config-dump: ");
|
||||
|
||||
@@ -73,7 +73,12 @@ bool testcase_hill::run() {
|
||||
uint64_t committed_serial = serial_count;
|
||||
unsigned txn_nops = 0;
|
||||
|
||||
bool rc = false;
|
||||
bool rc = speculum_verify();
|
||||
if (!rc) {
|
||||
log_notice("uphill: bailout before main loop");
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
while (should_continue()) {
|
||||
const keygen::serial_t a_serial = serial_count;
|
||||
if (unlikely(!keyvalue_maker.increment(serial_count, 1))) {
|
||||
|
||||
@@ -128,6 +128,8 @@ void testcase_nested::push_txn() {
|
||||
std::move(speculum_snapshot));
|
||||
log_verbose("begin level#%zu txn #%" PRIu64 ", flags 0x%x, serial %" PRIu64,
|
||||
stack.size(), mdbx_txn_id(nested_txn), flags, serial);
|
||||
if (!dbi && stack.size() == 1)
|
||||
dbi = db_table_open(true);
|
||||
}
|
||||
|
||||
bool testcase_nested::pop_txn(bool abort) {
|
||||
@@ -139,6 +141,9 @@ bool testcase_nested::pop_txn(bool abort) {
|
||||
log_verbose(
|
||||
"abort level#%zu txn #%" PRIu64 ", undo serial %" PRIu64 " <- %" PRIu64,
|
||||
stack.size(), mdbx_txn_id(txn), serial, std::get<1>(stack.top()));
|
||||
if (dbi > 0 && stack.size() == 1 &&
|
||||
is_handle_created_in_current_txn(dbi, txn))
|
||||
dbi = 0;
|
||||
int err = mdbx_txn_abort(txn);
|
||||
if (unlikely(err != MDBX_SUCCESS))
|
||||
failure_perror("mdbx_txn_abort()", err);
|
||||
|
||||
365
test/stochastic_small.sh
Executable file
365
test/stochastic_small.sh
Executable file
@@ -0,0 +1,365 @@
|
||||
#!/usr/bin/env bash
|
||||
if ! which make cc c++ tee >/dev/null; then
|
||||
echo "Please install the following prerequisites: make cc c++ tee banner" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LIST=--hill
|
||||
FROM=1
|
||||
UPTO=9999
|
||||
MONITOR=
|
||||
LOOPS=
|
||||
SKIP_MAKE=no
|
||||
BANNER="$(which banner 2>/dev/null | echo echo)"
|
||||
UNAME="$(uname -s 2>/dev/null || echo Unknown)"
|
||||
DB_UPTO_MB=17408
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
case "$1" in
|
||||
--help)
|
||||
echo "--multi Engage multi-process test scenario (default)"
|
||||
echo "--single Execute series of single-process tests (for QEMU, etc)"
|
||||
echo "--with-valgrind Run tests under Valgrind's memcheck tool"
|
||||
echo "--skip-make Don't (re)build libmdbx and test's executable"
|
||||
echo "--from NN Start iterating from the NN ops per test case"
|
||||
echo "--upto NN Don't run tests with more than NN ops per test case"
|
||||
echo "--loops NN Stop after the NN loops"
|
||||
echo "--dir PATH Specifies directory for test DB and other files (it will be cleared)"
|
||||
echo "--db-upto-mb NN Limits upper size of test DB to the NN megabytes"
|
||||
echo "--help Print this usage help and exit"
|
||||
exit -2
|
||||
;;
|
||||
--multi)
|
||||
LIST=basic
|
||||
;;
|
||||
--single)
|
||||
LIST="--nested --hill --append --ttl --copy"
|
||||
;;
|
||||
--with-valgrind)
|
||||
echo " NOTE: Valgrind could produce some false-positive warnings"
|
||||
echo " in multi-process environment with shared memory."
|
||||
echo " For instance, when the process 'A' explicitly marks a memory"
|
||||
echo " region as 'undefined', the process 'B' fill it,"
|
||||
echo " and after this process 'A' read such region, etc."
|
||||
MONITOR="valgrind --trace-children=yes --log-file=valgrind-%p.log --leak-check=full --track-origins=yes --error-exitcode=42 --suppressions=test/valgrind_suppress.txt"
|
||||
rm -f valgrind-*.log
|
||||
;;
|
||||
--skip-make)
|
||||
SKIP_MAKE=yes
|
||||
;;
|
||||
--from)
|
||||
FROM=$(($2))
|
||||
if [ -z "$FROM" -o "$FROM" -lt 1 ]; then
|
||||
echo "Invalid value '$FROM' for --from option"
|
||||
exit -2
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--upto)
|
||||
UPTO=$(($2))
|
||||
if [ -z "$UPTO" -o "$UPTO" -lt 1 ]; then
|
||||
echo "Invalid value '$UPTO' for --upto option"
|
||||
exit -2
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--loops)
|
||||
LOOPS=$(($2))
|
||||
if [ -z "$LOOPS" -o "$LOOPS" -lt 1 -o "$LOOPS" -gt 99 ]; then
|
||||
echo "Invalid value '$LOOPS' for --loops option"
|
||||
exit -2
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--dir)
|
||||
TESTDB_DIR="$2"
|
||||
if [ -z "$TESTDB_DIR" ]; then
|
||||
echo "Invalid value '$TESTDB_DIR' for --dir option"
|
||||
exit -2
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--db-upto-mb)
|
||||
DB_UPTO_MB=$(($2))
|
||||
if [ -z "$DB_UPTO_MB" -o "$DB_UPTO_MB" -lt 1 -o "$DB_UPTO_MB" -gt 4194304 ]; then
|
||||
echo "Invalid value '$DB_UPTO_MB' for --db-upto-mb option"
|
||||
exit -2
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option '$1'"
|
||||
exit -2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
set -euo pipefail
|
||||
if [ -z "$MONITOR" ]; then
|
||||
if which time >/dev/null 2>/dev/null; then
|
||||
MONITOR=$(which time)
|
||||
if $MONITOR -o /dev/stdout true >/dev/null 2>/dev/null; then
|
||||
MONITOR="$MONITOR -o /dev/stdout"
|
||||
fi
|
||||
fi
|
||||
export MALLOC_CHECK_=7 MALLOC_PERTURB_=42
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# 1. clean data from prev runs and examine available RAM
|
||||
|
||||
WANNA_MOUNT=0
|
||||
case ${UNAME} in
|
||||
Linux)
|
||||
MAKE=make
|
||||
if [ -z "${TESTDB_DIR:-}" ]; then
|
||||
for old_test_dir in $(ls -d /dev/shm/mdbx-test.[0-9]* 2>/dev/null); do
|
||||
rm -rf $old_test_dir
|
||||
done
|
||||
TESTDB_DIR="/dev/shm/mdbx-test.$$"
|
||||
fi
|
||||
mkdir -p $TESTDB_DIR && rm -f $TESTDB_DIR/*
|
||||
|
||||
if LC_ALL=C free | grep -q -i available; then
|
||||
ram_avail_mb=$(($(LC_ALL=C free | grep -i Mem: | tr -s [:blank:] ' ' | cut -d ' ' -f 7) / 1024))
|
||||
else
|
||||
ram_avail_mb=$(($(LC_ALL=C free | grep -i Mem: | tr -s [:blank:] ' ' | cut -d ' ' -f 4) / 1024))
|
||||
fi
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
MAKE=gmake
|
||||
if [ -z "${TESTDB_DIR:-}" ]; then
|
||||
for old_test_dir in $(ls -d /tmp/mdbx-test.[0-9]* 2>/dev/null); do
|
||||
umount $old_test_dir && rm -r $old_test_dir
|
||||
done
|
||||
TESTDB_DIR="/tmp/mdbx-test.$$"
|
||||
rm -rf $TESTDB_DIR && mkdir -p $TESTDB_DIR
|
||||
WANNA_MOUNT=1
|
||||
else
|
||||
mkdir -p $TESTDB_DIR && rm -f $TESTDB_DIR/*
|
||||
fi
|
||||
ram_avail_mb=$(($(LC_ALL=C vmstat -s | grep -ie '[0-9] pages free$' | cut -d p -f 1) * ($(LC_ALL=C vmstat -s | grep -ie '[0-9] bytes per page$' | cut -d b -f 1) / 1024) / 1024))
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
MAKE=make
|
||||
if [ -z "${TESTDB_DIR:-}" ]; then
|
||||
for vol in $(ls -d /Volumes/mdx[0-9]*[0-9]tst 2>/dev/null); do
|
||||
disk=$(mount | grep $vol | cut -d ' ' -f 1)
|
||||
echo "umount: volume $vol disk $disk"
|
||||
hdiutil unmount $vol -force
|
||||
hdiutil detach $disk
|
||||
done
|
||||
TESTDB_DIR="/Volumes/mdx$$tst"
|
||||
WANNA_MOUNT=1
|
||||
else
|
||||
mkdir -p $TESTDB_DIR && rm -f $TESTDB_DIR/*
|
||||
fi
|
||||
pagesize=$(($(LC_ALL=C vm_stat | grep -o 'page size of [0-9]\+ bytes' | cut -d' ' -f 4) / 1024))
|
||||
freepages=$(LC_ALL=C vm_stat | grep '^Pages free:' | grep -o '[0-9]\+\.$' | cut -d'.' -f 1)
|
||||
ram_avail_mb=$((pagesize * freepages / 1024))
|
||||
echo "pagesize ${pagesize}K, freepages ${freepages}, ram_avail_mb ${ram_avail_mb}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "FIXME: ${UNAME} not supported by this script"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -f ${TESTDB_DIR}/*
|
||||
|
||||
###############################################################################
|
||||
# 2. estimate reasonable RAM space for test-db
|
||||
|
||||
echo "=== ${ram_avail_mb}M RAM available"
|
||||
ram_reserve4logs_mb=1234
|
||||
if [ $ram_avail_mb -lt $ram_reserve4logs_mb ]; then
|
||||
echo "=== At least ${ram_reserve4logs_mb}Mb RAM required"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
#
|
||||
# В режимах отличных от MDBX_WRITEMAP изменения до записи в файл
|
||||
# будут накапливаться в памяти, что может потребовать свободной
|
||||
# памяти размером с БД. Кроме этого, в тест входит сценарий
|
||||
# создания копия БД на ходу. Поэтому БД не может быть больше 1/3
|
||||
# от доступной памяти. Однако, следует учесть что malloc() будет
|
||||
# не сразу возвращать выделенную память системе, а также
|
||||
# предусмотреть места для логов.
|
||||
#
|
||||
# In non-MDBX_WRITEMAP modes, updates (dirty pages) will
|
||||
# accumulate in memory before writing to the disk, which may
|
||||
# require a free memory up to the size of a whole database. In
|
||||
# addition, the test includes a script create a copy of the
|
||||
# database on the go. Therefore, the database cannot be more 1/3
|
||||
# of available memory. Moreover, should be taken into account
|
||||
# that malloc() will not return the allocated memory to the
|
||||
# system immediately, as well some space is required for logs.
|
||||
#
|
||||
db_size_mb=$(((ram_avail_mb - ram_reserve4logs_mb) / 4))
|
||||
if [ $db_size_mb -gt $DB_UPTO_MB ]; then
|
||||
db_size_mb=$DB_UPTO_MB
|
||||
fi
|
||||
echo "=== use ${db_size_mb}M for DB"
|
||||
|
||||
###############################################################################
|
||||
# 3. Create test-directory in ramfs/tmpfs, i.e. create/format/mount if required
|
||||
case ${UNAME} in
|
||||
Linux)
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
if [[ WANNA_MOUNT ]]; then
|
||||
mount -t tmpfs tmpfs $TESTDB_DIR
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
if [[ WANNA_MOUNT ]]; then
|
||||
ramdisk_size_mb=$((42 + db_size_mb * 2 + ram_reserve4logs_mb))
|
||||
number_of_sectors=$((ramdisk_size_mb * 2048))
|
||||
ramdev=$(hdiutil attach -nomount ram://${number_of_sectors})
|
||||
diskutil erasevolume ExFAT "mdx$$tst" ${ramdev}
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "FIXME: ${UNAME} not supported by this script"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
###############################################################################
|
||||
# 4. build the test executables
|
||||
|
||||
if [ "$SKIP_MAKE" != "yes" ]; then
|
||||
${MAKE} -j$(which nproc >/dev/null 2>/dev/null && nproc || echo 2) build-test
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# 5. run stochastic iterations
|
||||
|
||||
if which lz4 >/dev/null; then
|
||||
function logger {
|
||||
lz4 > ${TESTDB_DIR}/long.log.lz4
|
||||
}
|
||||
elif which gzip >/dev/null; then
|
||||
function logger {
|
||||
gzip > ${TESTDB_DIR}/long.log.gz
|
||||
}
|
||||
else
|
||||
function logger {
|
||||
cat > ${TESTDB_DIR}/long.log
|
||||
}
|
||||
fi
|
||||
|
||||
syncmodes=("" ,+nosync-safe ,+nosync-utterly)
|
||||
options=(writemap coalesce lifo notls perturb)
|
||||
|
||||
function join { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
function bits2options {
|
||||
local bits=$1
|
||||
local i
|
||||
local list=()
|
||||
for ((i = 0; i < ${#options[@]}; ++i)); do
|
||||
list[$i]=$( (( (bits & (1 << i)) != 0 )) && echo -n '+' || echo -n '-'; echo ${options[$i]})
|
||||
done
|
||||
join , ${list[@]}
|
||||
}
|
||||
|
||||
function failed {
|
||||
echo "FAILED" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function check_deep {
|
||||
if [ "$case" = "basic" -o "$case" = "--hill" ]; then
|
||||
tee >(logger) | grep -e reach -e achieve
|
||||
else
|
||||
logger
|
||||
fi
|
||||
}
|
||||
|
||||
function probe {
|
||||
echo "----------------------------------------------- $(date)"
|
||||
echo "${caption}"
|
||||
rm -f ${TESTDB_DIR}/* || failed
|
||||
for case in $LIST
|
||||
do
|
||||
echo "Run ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=1 --pathname=${TESTDB_DIR}/long.db --cleanup-after=no $@ $case"
|
||||
${MONITOR} ./mdbx_test ${speculum} --random-writemap=no --ignore-dbfull --repeat=1 --pathname=${TESTDB_DIR}/long.db --cleanup-before=yes --cleanup-after=no "$@" $case | check_deep \
|
||||
&& ${MONITOR} ./mdbx_chk ${TESTDB_DIR}/long.db | tee ${TESTDB_DIR}/long-chk.log \
|
||||
&& ([ ! -e ${TESTDB_DIR}/long.db-copy ] || ${MONITOR} ./mdbx_chk ${TESTDB_DIR}/long.db-copy | tee ${TESTDB_DIR}/long-chk-copy.log) \
|
||||
|| failed
|
||||
done
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
count=0
|
||||
loop=0
|
||||
cases='?'
|
||||
for ((wbatch=FROM; wbatch<=UPTO; ++wbatch)); do
|
||||
if [ -n "$LOOPS" ] && [ $loop -ge "$LOOPS" ]; then echo "The '--loops $LOOPS' limit reached"; break; fi
|
||||
echo "======================================================================="
|
||||
speculum=$([ $wbatch -le 1000 ] && echo '--speculum' || true)
|
||||
nops=$((wbatch/7 + 1))
|
||||
for ((rep=1; rep < 11; ++rep)); do
|
||||
echo "======================================================================="
|
||||
${BANNER} "$nops / $wbatch, repeat $rep"
|
||||
subcase=0
|
||||
for ((bits=2**${#options[@]}; --bits >= 0; )); do
|
||||
seed=$(($(date +%s) + RANDOM))
|
||||
|
||||
split=30
|
||||
caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
|
||||
split=24
|
||||
caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
|
||||
split=16
|
||||
caption="Probe #$((++count)) int-key,w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
caption="Probe #$((++count)) w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
|
||||
split=4
|
||||
caption="Probe #$((++count)) int-key,w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
caption="Probe #$((++count)) w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \
|
||||
--pagesize=4K --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \
|
||||
--nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%3]} \
|
||||
--keygen.seed=${seed}
|
||||
done # options
|
||||
cases="${subcase}"
|
||||
done # repeats
|
||||
loop=$((loop + 1))
|
||||
if [ -n "$LOOPS" ] && [ $loop -ge "$LOOPS" ]; then break; fi
|
||||
done # wbatch
|
||||
|
||||
echo "=== ALL DONE ====================== $(date)"
|
||||
68
test/test.cc
68
test/test.cc
@@ -477,6 +477,15 @@ void testcase::update_canary(uint64_t increment) {
|
||||
log_trace("<< update_canary: sequence = %" PRIu64, canary_now.y);
|
||||
}
|
||||
|
||||
bool testcase::is_handle_created_in_current_txn(const MDBX_dbi handle,
|
||||
MDBX_txn *txn) {
|
||||
unsigned flags, state;
|
||||
int err = mdbx_dbi_flags_ex(txn, handle, &flags, &state);
|
||||
if (unlikely(err != MDBX_SUCCESS))
|
||||
failure_perror("mdbx_dbi_flags_ex()", err);
|
||||
return (state & MDBX_DBI_CREAT) != 0;
|
||||
}
|
||||
|
||||
int testcase::db_open__begin__table_create_open_clean(MDBX_dbi &handle) {
|
||||
db_open();
|
||||
|
||||
@@ -484,6 +493,9 @@ int testcase::db_open__begin__table_create_open_clean(MDBX_dbi &handle) {
|
||||
for (;;) {
|
||||
txn_begin(false);
|
||||
handle = db_table_open(true);
|
||||
|
||||
if (is_handle_created_in_current_txn(handle, txn_guard.get()))
|
||||
return MDBX_SUCCESS;
|
||||
db_table_clear(handle);
|
||||
err = breakable_commit();
|
||||
if (likely(err == MDBX_SUCCESS)) {
|
||||
@@ -629,7 +641,8 @@ enum speculum_cursors : int {
|
||||
prev = 1,
|
||||
prev_prev = 2,
|
||||
next = 3,
|
||||
next_next = 4
|
||||
next_next = 4,
|
||||
seek_check = 5
|
||||
};
|
||||
|
||||
bool testcase::is_same(const Item &a, const Item &b) const {
|
||||
@@ -703,7 +716,7 @@ void testcase::speculum_check_cursor(const char *where, const char *stage,
|
||||
// verbose(where, stage, cursor_key, cursor_data, cursor_err);
|
||||
// verbose(where, stage, it);
|
||||
if (cursor_err != MDBX_SUCCESS && cursor_err != MDBX_NOTFOUND &&
|
||||
cursor_err != MDBX_RESULT_TRUE)
|
||||
cursor_err != MDBX_RESULT_TRUE && cursor_err != MDBX_ENODATA)
|
||||
failure("speculum-%s: %s %s %d %s", where, stage, "cursor-get", cursor_err,
|
||||
mdbx_strerror(cursor_err));
|
||||
|
||||
@@ -840,11 +853,26 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata,
|
||||
int err;
|
||||
bool rc = true;
|
||||
Item item;
|
||||
#if SPECULUM_CURSORS
|
||||
MDBX_cursor *check_seek_cursor = nullptr;
|
||||
MDBX_val seek_check_key, seek_check_data;
|
||||
int seek_check_err = 42;
|
||||
#endif /* SPECULUM_CURSORS */
|
||||
if (config.params.speculum) {
|
||||
item.first = iov2dataview(akey);
|
||||
item.second = iov2dataview(adata);
|
||||
#if SPECULUM_CURSORS
|
||||
speculum_prepare_cursors(item);
|
||||
check_seek_cursor = speculum_cursors[seek_check].get();
|
||||
seek_check_key = akey->value;
|
||||
seek_check_data = adata->value;
|
||||
seek_check_err = mdbx_cursor_get(
|
||||
check_seek_cursor, &seek_check_key, &seek_check_data,
|
||||
(config.params.table_flags & MDBX_DUPSORT) ? MDBX_GET_BOTH
|
||||
: MDBX_SET_KEY);
|
||||
if (seek_check_err != MDBX_SUCCESS && seek_check_err != MDBX_NOTFOUND)
|
||||
failure("speculum-%s: %s pre-insert %d %s", "insert", "seek",
|
||||
seek_check_err, mdbx_strerror(seek_check_err));
|
||||
#endif /* SPECULUM_CURSORS */
|
||||
}
|
||||
|
||||
@@ -869,6 +897,26 @@ int testcase::insert(const keygen::buffer &akey, const keygen::buffer &adata,
|
||||
}
|
||||
|
||||
#if SPECULUM_CURSORS
|
||||
if (insertion_result.second) {
|
||||
if (seek_check_err != MDBX_NOTFOUND) {
|
||||
log_error(
|
||||
"speculum.pre-insert-seek: unexpected %d {%s, %s}", seek_check_err,
|
||||
mdbx_dump_val(&seek_check_key, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&seek_check_data, dump_value, sizeof(dump_value)));
|
||||
rc = false;
|
||||
}
|
||||
} else {
|
||||
if (seek_check_err != MDBX_SUCCESS) {
|
||||
log_error(
|
||||
"speculum.pre-insert-seek: unexpected %d {%s, %s}", seek_check_err,
|
||||
mdbx_dump_val(&seek_check_key, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&seek_check_data, dump_value, sizeof(dump_value)));
|
||||
speculum_check_iterator("insert", "pre-seek", insertion_result.first,
|
||||
seek_check_key, seek_check_data);
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (insertion_result.first != speculum.begin()) {
|
||||
const auto cursor_prev = speculum_cursors[prev].get();
|
||||
auto it_prev = insertion_result.first;
|
||||
@@ -1038,6 +1086,15 @@ bool testcase::speculum_verify() {
|
||||
MDBX_val akey, avalue;
|
||||
MDBX_val mkey, mvalue;
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_FIRST);
|
||||
if (err == MDBX_NOTFOUND) {
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_GET_CURRENT);
|
||||
if (err == MDBX_ENODATA)
|
||||
err = MDBX_NOTFOUND;
|
||||
else {
|
||||
log_error("unexpected %d for MDBX_GET_CURRENT on empty DB", err);
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned extra = 0, lost = 0, n = 0;
|
||||
assert(std::is_sorted(speculum.cbegin(), speculum.cend(), ItemCompare(this)));
|
||||
@@ -1116,6 +1173,13 @@ bool testcase::speculum_verify() {
|
||||
log_error("false-negative cursor-eof: %u, rc %i", n, eof);
|
||||
rc = false;
|
||||
}
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_GET_CURRENT);
|
||||
if (err == MDBX_SUCCESS)
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_NEXT);
|
||||
if (err != MDBX_ENODATA) {
|
||||
log_error("unexpected %d for MDBX_GET_CURRENT at EOF", err);
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
mdbx_cursor_close(cursor);
|
||||
return rc;
|
||||
|
||||
@@ -202,7 +202,7 @@ protected:
|
||||
#define SPECULUM_CURSORS 1
|
||||
#endif /* SPECULUM_CURSORS */
|
||||
#if SPECULUM_CURSORS
|
||||
scoped_cursor_guard speculum_cursors[5];
|
||||
scoped_cursor_guard speculum_cursors[5 + 1];
|
||||
void speculum_prepare_cursors(const Item &item);
|
||||
void speculum_check_cursor(const char *where, const char *stage,
|
||||
const testcase::SET::const_iterator &it,
|
||||
@@ -268,6 +268,7 @@ protected:
|
||||
void db_table_clear(MDBX_dbi handle, MDBX_txn *txn = nullptr);
|
||||
void db_table_close(MDBX_dbi handle);
|
||||
int db_open__begin__table_create_open_clean(MDBX_dbi &handle);
|
||||
bool is_handle_created_in_current_txn(const MDBX_dbi handle, MDBX_txn *txn);
|
||||
|
||||
bool wait4start();
|
||||
void report(size_t nops_done);
|
||||
|
||||
Reference in New Issue
Block a user