-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Conversation
There was a problem hiding this 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.
db/version_edit.cc
Outdated
@@ -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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@cheng-chang has updated the pull request. You must reimport the pull request before landing. |
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. |
@cheng-chang has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this 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.
@cheng-chang has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this 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.
There was a problem hiding this 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.
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? |
@cheng-chang has updated the pull request. You must reimport the pull request before landing. |
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. |
There was a problem hiding this 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.
Got it, I missed this detail earlier, ignore my suggestion then here and questions in group chat |
@Cheng-Chang merged this pull request in e449482. |
) 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
) 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
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). |
…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
Although the tags for
WalAddition
,WalDeletion
are afterkTagSafeIgnoreMask
, 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
orWalDeletion
, it can settrack_and_verify_wals_in_manifest
tofalse
, then restart twice, then downgrade. On the first restart, a new MANIFEST will be created with aWalDeletion
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 neitherWalAddition
norWalDeletion
. 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 thankTagSafeIgnoreMask
can actually be skipped and won't affect parsing of other entries.