Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Use new ChecksummedBlock in DataCache #572
Use new ChecksummedBlock in DataCache #572
Changes from 1 commit
016cd7b
4b18b78
162aa16
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 was wondering if it might be nicer to have just one implementation of this stuff, and give
ChecksummedBytes
ashrink_to_fit
-style method to get the guarantee you're looking for. But then I guess that makesextend
et al more complicated because you have to handle all the different combinations to decide when you can skip validating the checksums, so probably not worth it?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.
After all, I think
shrink_to_fit
would be a better approach and can also be used to improveextend
. I will close this PR and open a new one with that change.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.
For these cases you probably need to validate the checksum of the empty side (which will be trivial to compute because they're zero-length slices), because the length might have been corrupted.
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 think this is safe since we are taking two checksummed buffers, combining the two, and calculating the new checksum independently of the new buffer.
IMO the durability risk here is mitigated, but I'd also like a second opinion from the team.
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.
Yeah, that sounds right. We know the expected checksum of each side (unlike in the
ChecksummedBytes
case where we only know the checksum of some larger slice of each side), and can compute the new expected checksum from those without actually looking at the bytes.Can you add a comment here capturing that reasoning?
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.
Do we ever use this as public API? If not, might be better to make it private, since it kinda invites time-of-check/time-of-use problems.
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'd leave this public:
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.
Doesn't really matter since it's just test code, but I think you want to do it this way to be correctly bracketed:
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 should be unreachable? here we know the bytes are equal but the checksums aren't, but they both passed validation?