-
Notifications
You must be signed in to change notification settings - Fork 261
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
[TieredStorage] Refactor TieredStorage::new_readonly() code path #195
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #195 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 837 837
Lines 226898 226932 +34
=======================================
+ Hits 185871 185953 +82
+ Misses 41027 40979 -48 |
The test failure doesn't seem related to the PR. Will rebase after the PR is fully reviewed.
|
ef767f1
to
0c298f5
Compare
Rebase to address the unrelated CI failure. |
0c7cf9c
to
a4762f2
Compare
Squash and rebase to include recent tiered-storage PRs. |
a4762f2
to
daf43bf
Compare
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.
looks good, just some nits
// This field is persisted in the storage but not in this struct. | ||
// The number should match FOOTER_MAGIC_NUMBER. | ||
// The number should match FILE_MAGIC_NUMBER. | ||
// pub magic_number: u64, |
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.
IMO the magic number is not part of the footer. And thus this part can be removed. I know this'll cause other necessary changes, so no need to change anything in this PR. (And it's pretty low priority, so no need to address this immediately.)
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.
Magic number is not part of the footer as it is commented out. The comment is to point out that there is one additional field after the footer (and the magic_number: u64
is also commented out). Maybe we can find a better place for this comment.
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.
It's not part of the struct, but it is part of FOOTER_TAIL_SIZE
, so we sometimes consider the magic number as part of the footer.
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.
It's not part of the struct, but it is part of FOOTER_TAIL_SIZE, so we sometimes consider the magic number as part of the footer.
Aghh, got it. The concept of FOOTER_TAIL_SIZE is that the format of the last FOOTER_TAIL_SIZE
bytes in any tiered-storage files will not change so that even if we have new versions of the footer that introduces new fields, we can still safely check the magic number and the format version. The tail also has a field describing the size of the footer.
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.
// This field is persisted in the storage but not in this struct. | ||
// The number should match FOOTER_MAGIC_NUMBER. | ||
// The number should match FILE_MAGIC_NUMBER. | ||
// pub magic_number: u64, |
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.
It's not part of the struct, but it is part of FOOTER_TAIL_SIZE
, so we sometimes consider the magic number as part of the footer.
…a-xyz#195) #### Problem The TieredStorage::new_readonly() function currently has the following problems: * It opens the file without checking the magic number before checking and loading the footer. * It opens the file twice: first to load the footer, then open again by the reader. #### Summary of Changes This PR refactors TieredStorage::new_readonly() so that it first performs all checks inside the constructor of TieredReadableFile. The TieredReadableFile instance is then passed to the proper reader (currently HotStorageReader) when all checks are passed. #### Test Plan * Added a new test to check MagicNumberMismatch. * Existing tiered-storage tests
Problem
The TieredStorage::new_readonly() function currently has the following
problems:
Summary of Changes
This PR refactors TieredStorage::new_readonly() so that it first performs all
checks inside the constructor of TieredReadableFile. The TieredReadableFile
instance is then passed to the proper reader (currently HotStorageReader)
when all checks are passed.
Test Plan