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 it able to ignore WAL related VersionEdits in older versions #7873

Closed
wants to merge 5 commits into from
Closed

Make it able to ignore WAL related VersionEdits in older versions #7873

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 16, 2021

Although the tags for WalAddition, WalDeletion are after kTagSafeIgnoreMask, to actually be able to skip these entries in older versions of RocksDB, we require that they are encoded with their encoded size as the prefix. This requirement is not met in the current codebase, so a downgraded DB may fail to open if these entries exist in the MANIFEST.

If a DB wants to downgrade, and its MANIFEST contains WalAddition or WalDeletion, it can set track_and_verify_wals_in_manifest to false, then restart twice, then downgrade. On the first restart, a new MANIFEST will be created with a WalDeletion indicating that all previously tracked WALs are removed from MANIFEST. On the second restart, since there is no tracked WALs in MANIFEST now, a new MANIFEST will be created with neither WalAddition nor WalDeletion. Then the DB can downgrade.

Tags for BlobFileAddition, BlobFileGarbage also have the same problem, but this PR focuses on solving the problem for WAL edits.

Test Plan:
Added a VersionEditTest::IgnorableTags unit test to verify all entries with tags larger than kTagSafeIgnoreMask can actually be skipped and won't affect parsing of other entries.

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.

@@ -217,22 +217,30 @@ bool VersionEdit::EncodeTo(std::string* dst) const {

for (const auto& blob_file_addition : blob_file_additions_) {
PutVarint32(dst, kBlobFileAddition);
blob_file_addition.EncodeTo(dst);
std::string encoded;
Copy link
Author

Choose a reason for hiding this comment

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

@ltamasi This breaks backward compatibility. But without doing so, users of BlobDB cannot downgrade. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

I'll remove changes related to BlobDB from this PR to make it focus on WAL edits.

Copy link
Contributor

@ltamasi ltamasi Jan 19, 2021

Choose a reason for hiding this comment

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

@ltamasi This breaks backward compatibility. But without doing so, users of BlobDB cannot downgrade. What do you think?

Nice catch @Cheng-Chang, and thanks for letting me know! In hindsight, the blob file related tags shouldn't have been put in the "ignorable" range since if you have blob files and downgrade to a version that cannot read these, you won't be able to read your data. Fortunately, since these are related to the integrated BlobDB project (which is WIP), we can still move these to the "non-ignorable" range. I'll take care of that.

@ghost ghost changed the title Make it able to ignore blob and WAL related VersionEdits in older versions Make it able to ignore WAL related VersionEdits in older versions Jan 16, 2021
@facebook-github-bot
Copy link
Contributor

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

@anand1976
Copy link
Contributor

As @ltamasi points out for the BlobDB entries, wouldn't this change cause problems when upgrading? Maybe we could introduce new tags with the correct format, and retain the existing ones to be able to decode?

@ghost
Copy link
Author

ghost commented Jan 19, 2021

As @ltamasi points out for the BlobDB entries, wouldn't this change cause problems when upgrading? Maybe we could introduce new tags with the correct format, and retain the existing ones to be able to decode?

Then when we do the downgrade to a version older than 6.15, it still fails to be decoded unless we restart DB twice to remove the entries. I'm thinking maybe we can fix the format here. During upgrade, if there is decoding issue, the user can restart DB twice to get rid of the existing WAL related entries, and then upgrade.

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

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.

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

Should we be pessimistic and call them "kWal{Addition,Deletion}2"? It also helps since "new" is ambiguous -- in the case of kNewFile, "new" means the file is being added, I think.

@ajkr
Copy link
Contributor

ajkr commented Jan 19, 2021

Also can we have a "bug fixes" release note that mentions the downgrade instructions for users who ran 6.15.1 with WAL tracking enabled?

@facebook-github-bot
Copy link
Contributor

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

@ghost
Copy link
Author

ghost commented Jan 19, 2021

Also can we have a "bug fixes" release note that mentions the downgrade instructions for users who ran 6.15.1 with WAL tracking enabled?

The wal tracking is only released in 6.16. In 6.15, there is a comment on the option indicating that it's not ready for use yet. MyRocks accidentally enabled it in 6.15.

I think we'll mention this in 6.16.1's release note.

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.

@ajkr
Copy link
Contributor

ajkr commented Jan 20, 2021

MyRocks accidentally enabled it in 6.15.

Got it, I missed this detail earlier, ignore my suggestion then here and questions in group chat

@facebook-github-bot
Copy link
Contributor

@Cheng-Chang merged this pull request in e449482.

ghost pushed a commit that referenced this pull request Jan 20, 2021
)

Summary:
Although the tags for `WalAddition`, `WalDeletion` are after `kTagSafeIgnoreMask`, to actually be able to skip these entries in older versions of RocksDB, we require that they are encoded with their encoded size as the prefix. This requirement is not met in the current codebase, so a downgraded DB may fail to open if these entries exist in the MANIFEST.

If a DB wants to downgrade, and its MANIFEST contains `WalAddition` or `WalDeletion`, it can set `track_and_verify_wals_in_manifest` to `false`, then restart twice, then downgrade. On the first restart, a new MANIFEST will be created with a `WalDeletion` indicating that all previously tracked WALs are removed from MANIFEST. On the second restart, since there is  no tracked WALs in MANIFEST now, a new MANIFEST will be created with neither `WalAddition` nor `WalDeletion`. Then the DB can downgrade.

Tags for `BlobFileAddition`, `BlobFileGarbage` also have the same problem, but this PR focuses on solving the problem for WAL edits.

Pull Request resolved: #7873

Test Plan: Added a `VersionEditTest::IgnorableTags` unit test to verify all entries with tags larger than `kTagSafeIgnoreMask` can actually be skipped and won't affect parsing of other entries.

Reviewed By: ajkr

Differential Revision: D25935930

Pulled By: cheng-chang

fbshipit-source-id: 7a02fdba4311d6084328c14aed110a26d08c3efb
ghost pushed a commit that referenced this pull request Jan 20, 2021
)

Summary:
Although the tags for `WalAddition`, `WalDeletion` are after `kTagSafeIgnoreMask`, to actually be able to skip these entries in older versions of RocksDB, we require that they are encoded with their encoded size as the prefix. This requirement is not met in the current codebase, so a downgraded DB may fail to open if these entries exist in the MANIFEST.

If a DB wants to downgrade, and its MANIFEST contains `WalAddition` or `WalDeletion`, it can set `track_and_verify_wals_in_manifest` to `false`, then restart twice, then downgrade. On the first restart, a new MANIFEST will be created with a `WalDeletion` indicating that all previously tracked WALs are removed from MANIFEST. On the second restart, since there is  no tracked WALs in MANIFEST now, a new MANIFEST will be created with neither `WalAddition` nor `WalDeletion`. Then the DB can downgrade.

Tags for `BlobFileAddition`, `BlobFileGarbage` also have the same problem, but this PR focuses on solving the problem for WAL edits.

Pull Request resolved: #7873

Test Plan: Added a `VersionEditTest::IgnorableTags` unit test to verify all entries with tags larger than `kTagSafeIgnoreMask` can actually be skipped and won't affect parsing of other entries.

Reviewed By: ajkr

Differential Revision: D25935930

Pulled By: cheng-chang

fbshipit-source-id: 7a02fdba4311d6084328c14aed110a26d08c3efb
@ajkr
Copy link
Contributor

ajkr commented Jan 20, 2021

I think we'll mention this in 6.16.1's release note.

It makes sense. I hope the release note will appear on master branch as well, so that it's clear upgrading from 6.16.0 to a newer major/minor version also gets the fix, not just upgrading from 6.16.0 to 6.16.1 or a later patch version.

@ltamasi
Copy link
Contributor

ltamasi commented Jan 20, 2021

I think we'll mention this in 6.16.1's release note.

It makes sense. I hope the release note will appear on master branch as well, so that it's clear upgrading from 6.16.0 to a newer major/minor version also gets the fix, not just upgrading from 6.16.0 to 6.16.1 or a later patch version.

@Cheng-Chang Seems to me you've also cherry-picked this into 6.17, so I think we should also call it out in the 6.17.0 section of the changelog (on master and 6.17.fb as well).

codingrhythm pushed a commit to SafetyCulture/rocksdb that referenced this pull request Mar 5, 2021
…cebook#7873)

Summary:
Although the tags for `WalAddition`, `WalDeletion` are after `kTagSafeIgnoreMask`, to actually be able to skip these entries in older versions of RocksDB, we require that they are encoded with their encoded size as the prefix. This requirement is not met in the current codebase, so a downgraded DB may fail to open if these entries exist in the MANIFEST.

If a DB wants to downgrade, and its MANIFEST contains `WalAddition` or `WalDeletion`, it can set `track_and_verify_wals_in_manifest` to `false`, then restart twice, then downgrade. On the first restart, a new MANIFEST will be created with a `WalDeletion` indicating that all previously tracked WALs are removed from MANIFEST. On the second restart, since there is  no tracked WALs in MANIFEST now, a new MANIFEST will be created with neither `WalAddition` nor `WalDeletion`. Then the DB can downgrade.

Tags for `BlobFileAddition`, `BlobFileGarbage` also have the same problem, but this PR focuses on solving the problem for WAL edits.

Pull Request resolved: facebook#7873

Test Plan: Added a `VersionEditTest::IgnorableTags` unit test to verify all entries with tags larger than `kTagSafeIgnoreMask` can actually be skipped and won't affect parsing of other entries.

Reviewed By: ajkr

Differential Revision: D25935930

Pulled By: cheng-chang

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

None yet

4 participants