Level / leveldown

Pure C++ Node.js LevelDB binding. An abstract-leveldown compliant store.
MIT License
775 stars 176 forks source link

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

Closed vweevers closed 2 years ago

vweevers commented 2 years ago

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 commented 2 years ago

Tracked in https://github.com/Level/community/issues/118. It won't be fixed in leveldown, only its successor classic-level.