William Brown wrote:
Hi there,
While doing some integration testing of LMDB I noticed that there may be an issue with out of order transaction handling.
May be? Do you have sample code that demonstrates the existence of the issue?
The scenario is:
Open Read TXN A Open Write TXN X, and change values of the DB Commit X Open Read TXN B Open Write TXN Y, and change values of the DB Commit Y Open Read TXN C
Abort/Close TXN B.
At this point, because of the page touch between A -> B and B -> C,
What page touch? Read txns don't do any such thing,
B now believes that the pages of A are the "last time" they are available as they were all subsequently copied for TXN C. The pages of A are then added to the freelists when B closes.
That's not how it works at all. The freelist is only modified when write txns commit. Notthing changes when a read txn ends, either by commit or abort.
When TXN A is read from the data may have been altered due to future writes as LMDB attempts to use previously allocated pages first.
That's not how it works. As long as read txn A is open none of its pages will be reused.
This situation is more likely to arise on large batch writes, but could manifest with smaller series of writes. This would be a silent issue, as the over-written pages may be valid, and could cause data to "silently vanish" inside of the read transaction A leading to unpredictable results.
I hope that this report helps you to diagnose and resolve the issue.