Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When snapshot is created with db.get() #23

Closed
anseki opened this issue Apr 7, 2022 · 2 comments
Closed

When snapshot is created with db.get() #23

anseki opened this issue Apr 7, 2022 · 2 comments

Comments

@anseki
Copy link

anseki commented Apr 7, 2022

Hi, thank you for the great library.

I have a question about the document for snapshot with db.get().
https://github.com/Level/classic-level#dbgetkey-options-callback

The document said, the snapshot is created at the time db.get() was called.
I thought, this means that the snapshot is latest data for this calling.
However, the document also said, it should not see the data of simultaneous write operations.

Can the data be changed after db.get() was called (and the snapshot was created) and before db.get() returns the data?
That is, I understand that an iterator might return old data because that reads lazily it, but db.get() is not. Then I thought that db.get() returns latest data before something changes it.
Or, is there a way to get latest data?

Thank you.

@vweevers
Copy link
Member

Can the data be changed after db.get() was called (and the snapshot was created) and before db.get() returns the data?

In 1.x there is a brief window where the data can theoretically change in between the db.get() call and snapshot creation. This has been fixed in 2.0.0 (50e03dc). See Level/community#118 for background.

What this means is that db.get() is guaranteed to return the last data that was successfully written by your app prior to the db.get() call. It's the app's responsibility to await any prior write operations, if that data should be included in the snapshot.

@anseki
Copy link
Author

anseki commented Oct 21, 2024

Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants