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

Add an internal API MemTableList::GetEditForDroppingCurrentVersion #13001

Closed
wants to merge 2 commits into from

Conversation

jowlyzhang
Copy link
Contributor

Prepare this internal API to be used by atomic data replacement. The main purpose of this API is to get a VersionEdit to mark the entire current MemTableListVersion as dropped. Flush needs the similar functionality when installing results, so that logic is refactored into a util function GetDBRecoveryEditForObsoletingMemTables to be shared by flush and this internal API.

To test this internal API, flush's result installation is redirected to use this API when it is flushing all the immutable MemTables in debug mode. It should achieve the exact same results, just with a duplicated VersionEdit::log_number field that doesn't upsets the recovery logic.

Test plan:
Existing tests

@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.

}
edit_list.push_back(&wal_deletion);
#else
edit = GetDBRecoveryEditForObsoletingMemTables(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy-paste between debug-only and release-only code tempts the code to dangerously diverge, but it is only a couple of lines and temporary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this note! I was trying to split the work of atomic replacement into a few standalone pieces that can be reviewed separately. This internal API is one such piece but it's a dilemma to get it tested before implementing atomic replacement, so I added this temporary debug code.

Thanks for calling out the danger of diverging release mode vs debug mode. I'm gonna change this to make debug mode random chose between the two.

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.

There is a small inherent danger in doing something different in release mode vs. debug mode. We prefer to keep it to "extra checks" in debug mode that you can essentially prove don't affect other operations (assuming the checks pass).

Oddly, I would be less concerned if debug mode randomly chose between the two. Both would be covered then. Or you could use the code in one of our build variants like folly or ASSERT_STATUS_CHECKED or COERCE_CONTEXT_SWITCH, etc.

@facebook-github-bot
Copy link
Contributor

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

@jowlyzhang
Copy link
Contributor Author

Or you could use the code in one of our build variants like folly or ASSERT_STATUS_CHECKED

@pdillinger Thank you for the quick review and the suggestion! I have updated the code to only exercise this path in ASSERT_STATUS_CHECKED mode.

@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 merged this pull request in 43bc71f.

@jowlyzhang jowlyzhang deleted the internal_memtable_apis branch September 10, 2024 21:08
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