[Date Prev][Date Next] [Chronological] [Thread] [Top]

lmdb: is read operation permitted inside the write transaction?


this might be a trivial question for you but I didn't find anything in the documentation nor any mention in the examples.

Basically I need to have an opportunity to call mdb_get while in write transaction.
The sequence is smth like:
 - txn = mdb_txn_begin(flags=0)
 for i in 0..x:
   - v = mdb_get(txn, i)
   - mdb_put(txn, x+i, v)
   - mdb_put(txn, i, v+1)
 - mdb_txn_commit(txn)

Will it be always valid data?
I'm running a stress test and didn't spot any issues so far. Though I might be extremely lucky today.

The DB is used in multi-threaded environment but the code illustrated above is protected with a mutex.

I tried to dig a bit into the lmdb internals but unfortunately didn't get any glue.

Thanks for your help,