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

Introduce SuperSnapshot #292

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Introduce SuperSnapshot #292

merged 1 commit into from
Oct 19, 2023

Conversation

igorcanadi
Copy link

Summary:
SuperSnapshot is a combination of a snapshot and a super-version. They
fulfill the same goal as snapshots, i.e. provide a consistent view of
the database. However, unlike snapshots, they also pin the current
super-version (memtable, immutable memtable list and file LSM tree). In
that way they are similar to iterators, which also pin the current
super-version for the duration of their lifetime.

Test Plan:
Added a basic unit test.

Reviewers:

@igorcanadi
Copy link
Author

Just realized I also need to add support for MultiGet, adding that now.

@igorcanadi
Copy link
Author

Added MultiGet support together with the unit test.

read_options.background_purge_on_iterator_cleanup ||
immutable_db_options_.avoid_unnecessary_blocking_io);
internal_iter->RegisterCleanup(CleanupSuperVersionHandle, cleanup, nullptr);
// Do not clean up the super version if super snapshot owns it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that the super_version passed to NewInternalIterator is always the same as read_options.snapshot.sv_ here?

If so, how is that guarantee maintained?
If not, why can't we cleanup super_version here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking because NewInternalIterator is called in multiple places, but seems we only maintain the assumption in DBImpl::NewIteratorImpl.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the assumption here, and you're right that it's not respected in some scenarios (like iterator refresh, although iterator refresh is also not supported if snapshot is non-nullptr). I wll add a check to only avoid cleaning up if super_version is not the same as read_options.snapshot.sv_.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this comment in latest version of the code.

Summary:
SuperSnapshot is a combination of a snapshot and a super-version. They
fulfill the same goal as snapshots, i.e. provide a consistent view of
the database. However, unlike snapshots, they also pin the current
super-version (memtable, immutable memtable list and file LSM tree). In
that way they are similar to iterators, which also pin the current
super-version for the duration of their lifetime.

Test Plan:
Added a basic unit test.

Reviewers:
Copy link

@seckcoder seckcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@igorcanadi igorcanadi merged commit afdbcc0 into master Oct 19, 2023
0 of 2 checks passed
@aanq aanq deleted the igor_supersnapshot branch October 19, 2023 13:41
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

Successfully merging this pull request may close these issues.

3 participants