LMDB reader table
The LMDB reader table records reader process, thread and transaction identities so page reclamation can respect active snapshots.
In LMDB 0.9.33, mdb_find_oldest scans reader transaction IDs and allocation excludes free-list records that are too recent for that boundary. A live old snapshot can therefore delay reuse without holding the writer mutex. [3] A controlled experiment found that mdb_reader_check cleared zero slots and did not relieve the live-reader case; ending the reader allowed 64 more writes at the same map size. [4] A reset read-transaction handle is not an active snapshot; it must be renewed before reuse. [2]
Copy operations also hold read transactions. In a controlled pipe-stall test, reader checking did not release the live copying reader; write progress resumed after copy completion. Compact copying reduced destination size, not the source reader lifetime in that test. [6]
Process termination and reader-table cleanup are distinct. In the pinned POSIX implementation, stale-reader checking probes a process-associated byte-range lock, not kill(pid, 0). A controlled unreaped-child case cleared three entries belonging to one process; the reader list became empty while me_numreaders stayed at its high-water value of three. [3] [7]
The cleanup output counts cleared slots, not dead processes. A successful call can clear zero slots and leave a live snapshot blocking reuse; it is not a transaction-age timeout or a guarantee that the next write will succeed. [2] [7]
Relations
Limitations
- Map capacity, reusable pages and live payload bytes are different quantities; these test counts are not universal thresholds. [4]
Citations
- LMDB 0.9.33 API: transaction lifetime, reset/renew, map capacity and reader checks
- LMDB 0.9.33 implementation: mdb_find_oldest, mdb_page_alloc and mdb_reader_check0
- Hesela: controlled LMDB reader-lifetime experiment, complete results and limits
- Hesela: 24 controlled LMDB copy-backpressure observations, hashes and limits
- Hesela: 40 controlled LMDB reader-death and cleanup cases, method and limits