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

Carry over min_log_number_to_keep_2pc in new MANIFEST #7747

Closed
wants to merge 2 commits into from
Closed

Carry over min_log_number_to_keep_2pc in new MANIFEST #7747

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 5, 2020

When two phase commit is enabled, VersionSet::min_log_number_to_keep_2pc is set during flush.
But when a new MANIFEST is created, the min_log_number_to_keep_2pc is not carried over to the new MANIFEST. So if a new MANIFEST is created and then DB is reopened, the min_log_number_to_keep_2pc will be lost. This may cause DB recovery errors.
The bug is reproduced in a new unit test in version_set_test.cc.

Test Plan:
The new unit test in version_set_test.cc should pass.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@Cheng-Chang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ghost ghost requested a review from riversand963 December 8, 2020 18:30
@@ -5278,6 +5278,14 @@ Status VersionSet::WriteCurrentStateToManifest(
assert(iter != curr_state.end());
uint64_t log_number = iter->second.log_number;
edit.SetLogNumber(log_number);

if (cfd->GetID() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it only apply to default CF?

Copy link
Author

Choose a reason for hiding this comment

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

min_log_number_to_keep is for the whole db, not for specific column family.
So it does not need to be set for every column family, just need to be set once.
Since default CF can never be dropped, we set the min_log to the default CF here.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment for that?

@ghost ghost removed the request for review from riversand963 December 8, 2020 21:40
Copy link
Contributor

@jay-zhuang jay-zhuang left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @Cheng-Chang for the quick fix.

@@ -5278,6 +5278,14 @@ Status VersionSet::WriteCurrentStateToManifest(
assert(iter != curr_state.end());
uint64_t log_number = iter->second.log_number;
edit.SetLogNumber(log_number);

if (cfd->GetID() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment for that?

@facebook-github-bot
Copy link
Contributor

@cheng-chang has updated the pull request. You must reimport the pull request before landing.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@cheng-chang has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@Cheng-Chang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cheng-chang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@Cheng-Chang merged this pull request in 80159f6.

codingrhythm pushed a commit to SafetyCulture/rocksdb that referenced this pull request Mar 5, 2021
Summary:
When two phase commit is enabled, `VersionSet::min_log_number_to_keep_2pc` is set during flush.
But when a new MANIFEST is created, the `min_log_number_to_keep_2pc` is not carried over to the new MANIFEST. So if a new MANIFEST is created and then DB is reopened, the `min_log_number_to_keep_2pc` will be lost.  This may cause DB recovery errors.
The bug is reproduced in a new unit test in `version_set_test.cc`.

Pull Request resolved: facebook#7747

Test Plan: The new unit test in `version_set_test.cc` should pass.

Reviewed By: jay-zhuang

Differential Revision: D25350661

Pulled By: cheng-chang

fbshipit-source-id: eee890d5b19f15769069670692e270ae31044ece
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