-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
proto: re-implement MessageUtil::hash function to consistently hash Any recursively #8231
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
57972f1
proto: define a hash function can consistently hash Any and use in se…
lizan 14c2213
link protobuf issue
lizan 366e2ee
spell
lizan 7b289ec
use TextFormat directly
lizan 795c9be
negative test
lizan a20fca1
unify hash functions
lizan ee690d0
Merge remote-tracking branch 'upstream/master' into stable_hash_any
lizan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 seems incredibly fragile. Shouldn't the above function handle this correctly? Is there a protobuf issue tracking this that we can link to / TODO?
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, this seems pretty bad due to the expectation that debug string is stable in any way. I feel it might be one of the least bad things for now though. We might want to move away from using any form of protobuf hashing in the future, instead opting to only consider explicit UUIDs or versions.
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.
OK I updated the implementation to use TextFormat directly with more settings to TextFormat::Printer explicitly, as well as more test to validate map as well. Does this look better now?
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.
Sure, but TBH, I still think we should take a long term (beyond this PR) think and see if we can distance ourselves from proto hashing. There have been too many bugs here and proto is unlikely to standardize a hash due to the implications on serialization.
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.
+1, I'm not sure how the developer is supposed to know which of these to use. We need a holistic solution that avoids this problem entirely.
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.
(sorry to interrupt) I think using the resource version should take preference over hashing. There may be cases when the control plan wants to trigger a reload for a config that is structurally the same (e.g. references some modified file or resource by name).
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.
@mattklein123 @kyessenov Both SGTM, filed #8301 for further discussion, it is beyond the scope of this PR.
@mattklein123 how do you want this PR land? I can make this as default hash and use everywhere (solves potential issue in other places like RDS, but slightly less performant), or leave as is to at least solve SDS issue.
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.
My personal feeling is that we should use a single hash that works in all cases, even if it performs worse, until we see perf traces that prove that we shouldn't do that. @htuch any opinion?
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.
Yep, single hash function sounds best. If we can simplify and then only add in the necessary complexity for performance reasons, that would be ideal.
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.
Done and updated title/description.