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 flush create its own reference of MemTableListVersion #12996

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jowlyzhang
Copy link
Contributor

@jowlyzhang jowlyzhang commented Sep 5, 2024

This extra ref is redundant now but we need it for when data replacement can happen. This PR also changes the contract for cancelling a FlushJob and adds some TODOs for the flush code path for implementing atomic replacement.

FlushJob's cancellation is for properly releasing the resources it is holding. In this PR one more resource namely the MemTableListVersion is added into FlushJob, so I want to make sure it's properly handled. Currently, the caller of FlushJob's public APIs use a side by side boolean to track the need for cancellation on their side. That is a contract that cannot be enforced. For example, flush_job_test.cc is not doing that at all. Besides, this is also a complicated contract. There is setting that boolean to true / false in some conditions, checking it in combination with returned Status etc. That makes the contract error prone. There is also no enforcement that resources are guaranteed to be cleaned up.

In this PR, we added a required output variable need_cleanup to FlushJob's public APIs. The contract is: the user always need to call FlushJob::Cleanup as long as that boolean is set to true. Although this is yet one more output argument, FlushJob::Run already have a few other boolean output arguments of the same pattern so it's not too much extra cognitive burden. FlushJob maintains its own internal state about resource management, and a few extra guards are added in debug mode.

Test plan:
Existing tests

@jowlyzhang jowlyzhang marked this pull request as draft September 5, 2024 21:59
@jowlyzhang jowlyzhang changed the title Make flush create its own reference of MemTableListVersion [TEST ONLY]Make flush create its own reference of MemTableListVersion Sep 6, 2024
@jowlyzhang jowlyzhang changed the title [TEST ONLY]Make flush create its own reference of MemTableListVersion Make flush create its own reference of MemTableListVersion Sep 7, 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.

@jowlyzhang jowlyzhang marked this pull request as ready for review September 7, 2024 00:26
@jowlyzhang jowlyzhang marked this pull request as draft September 11, 2024 21:56
@jowlyzhang
Copy link
Contributor Author

This PR is paused because we are re-evaluating the need for the atomic replacement feature. I think updating a FlushJob's contract for cleanup is still worth doing. I will get back to this PR for that part.

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.

2 participants