leveldown icon indicating copy to clipboard operation
leveldown copied to clipboard

`db.get()` doesn't read from a snapshot

Open vweevers opened this issue 4 years ago • 0 comments

We don't set the LevelDB snapshot option for database_->Get(), so rather than reading from a snapshot created at the time that db.get() was called, it will read from an implicit snapshot (i.e. latest state) at the time the async worker runs:

https://github.com/Level/leveldown/blob/bd33f6fef9009643659bb2f65c825df3c758c1e9/binding.cc#L1123

For comparison, see db.getMany() where we do set the snapshot option:

https://github.com/Level/leveldown/blob/bd33f6fef9009643659bb2f65c825df3c758c1e9/binding.cc#L1173

This may have been the case for a long time and I've personally not found this to be a problem in real-world apps. Putting this in the backlog until there are upvotes.

vweevers avatar Dec 12 '21 12:12 vweevers