-
Notifications
You must be signed in to change notification settings - Fork 348
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
Fix the ContentHash implementations for std::Option and MergedTreeId and RemoteRefState #3061
Conversation
c690316
to
40f94ab
Compare
Of course I forgot to update all of the tests which are now failing since we changed the hash function... I'll mail a new commit once I've worked through the dozens of failures. |
We have one more enum:
Just fyi, what I usually do is:
|
40f94ab
to
512394e
Compare
I didn't see this before. Thanks for pointing it out. I'm not sure how to read the implementation for this one but it seems like it's non-conformant (even ignoring the u8) since I don't think Rust defines what tag values are used for the enum variants. I'll fix it in the morning and push a new commit. |
It's |
…d RemoteRefState The `ContentHash` documentation specifies that implementations for enums should hash the ordinal number of the variant contained in the enum as a 32-bit little-endian number and then hash the contents of the variant, if any. The current implementations for `std::Option`, `MergedTreeId`, and `RemoteRefState` are non-conformant since they hash the ordinal number as a u8 with platform specific endianness. Fixes #3051
512394e
to
500358b
Compare
For reference, note that
Implicit discriminant values are specified in the reference. |
Right, of course... brain fart.
Thanks, I was having trouble finding this for some reason. |
All the tests are passing, but when I ran
After that it seemed to run fine. When I ran my 0.13.0 stable binary again on the same repo I got a different error:
The difference in the message seems to be due to a change in the message itself in 1f6d1de6, which is very recent and not included in my stable binary. Again it seemed fine after re-indexing. I took a look at the code and I think everything will be ok, but would someone please confirm that this should be benign before I submit this change? @yuja I think you changed this index code most recently. What do you think? We should probably mention in the patch notes for the next release that users will see this error after upgrading. FYI @martinvonz Edit: This is in the patch notes for the next release:
Maybe we can change the migration code to just quietly rebuild the index with the new hash values so that users don't get confused by seeing an error? |
It's not a problem of this PR. I'm doing some index format changes in this release cycle.
That's doable, but I'm not sure which is better. Reindexing can take few tens of seconds in mid-size repos. |
That checks out. I did some more testing without this commit and I see the same error. Maybe we can just tweak the error message? The current message is:
Maybe we can just add (maybe the format has changed) to clarify that this might be ok.
It's an issue for a separate PR though. |
The
ContentHash
documentation specifies that implementations for enums should hash the ordinal number of the variant contained in the enum as a 32-bit little-endian number and then hash the contents of the variant, if any.The current implementations for
std::Option
andMergedTreeId
are non-conformant since they hash the ordinal number as a u8 with platform specific endianness.Fixes #3051