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

Make compaction always use the input version with extra ref protection #12992

Closed
wants to merge 3 commits into from

Conversation

jowlyzhang
Copy link
Contributor

@jowlyzhang jowlyzhang commented Sep 4, 2024

Compaction is already creating its own ref for the input Version:

input_version_->Ref();

And properly Unref it during destruction:

input_version_->Unref();

This PR redirects compaction's access of cfd->current() to this input Version, to prepare for when a column family's data can be replaced all together, and cfd->current() is not safe to access for a compaction job. Because a new Version with just some other external files could be installed as cfd->current(). The compaction job's expectation of the current Version and the corresponding storage info to always have its input files will no longer be guaranteed.

My next follow up is to do a similar thing for flush, also to prepare it for when a column family's data can be replaced. I will make it create its own reference of the current MemTableListVersion and use it as input, all flush job's access of memtables will be wired to that input MemTableListVersion. Similarly this reference will be unreffed during a flush job's destruction.

Test plan:
Existing tests

@jowlyzhang jowlyzhang changed the title [TEST ONLY]Make compaction always use the input version with extra ref protection Make compaction always use the input version with extra ref protection Sep 4, 2024
@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

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

LGTM

db/column_family.cc Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@jowlyzhang
Copy link
Contributor Author

LGTM

@pdillinger Thank you for the quick review!

@facebook-github-bot
Copy link
Contributor

@jowlyzhang merged this pull request in 0c6e9c0.

@jowlyzhang jowlyzhang deleted the prepare_compaction branch September 27, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants