https://bugs.openldap.org/show_bug.cgi?id=9920
--- Comment #18 from kero renault.cle@gmail.com --- I come back with more interesting information: The database seems corrupted when we use threads.
The following is the output of the redb benchmarks. The database becomes corrupted when multiple threads are spawned to read in the database simultaneously, one new transaction by thread.
I also made my program work correctly, without any LMDB error, by spawning the write transaction on the main thread instead of a dedicated thread. Unfortunately, this freezes the user interface but works correctly (a little slow, but that's probably due to decryption).
I still don't know if the problem arises from spawning a write transaction in another thread or because we are trying to read while writing. However, I'm sure that reading with multiple read transactions simultaneously corrupts the database/env.
redb: Bulk loaded 1000000 items in 2974ms redb: Wrote 100 individual items in 437ms redb: Wrote 100 x 1000 items in 4178ms redb: len() in 0ms redb: Random read 1000000 items in 714ms redb: Random read 1000000 items in 730ms redb: Random range read 10000000 elements in 1645ms redb: Random range read 10000000 elements in 1638ms redb: Random read (1 threads) 1000000 items in 723ms redb: Random read (4 threads) 1000000 items in 209ms redb: Random read (8 threads) 1000000 items in 184ms redb: Random read (16 threads) 1000000 items in 185ms redb: Random read (32 threads) 1000000 items in 185ms redb: Removed 500000 items in 2764ms heed: Bulk loaded 1000000 items in 7092ms heed: Wrote 100 individual items in 299ms heed: Wrote 100 x 1000 items in 79816ms heed: len() in 0ms heed: Random read 1000000 items in 7855ms heed: Random read 1000000 items in 911ms heed: Random range read 10000000 elements in 1298ms heed: Random range read 10000000 elements in 1306ms heed: Random read (1 threads) 1000000 items in 7598ms thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'called `Result::unwrap()` on an `Err` value: Mdb(Corrupted)called `Result::unwrap()` on an `Err` value: Mdb(Corrupted)', ', benches/common.rs:419:36 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace benches/common.rs:419:36