-
Notifications
You must be signed in to change notification settings - Fork 84
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
Ensure correct work UUID #1501
Comments
it would be a good way to provide a set of examples illustrating the problem and the practice of correction. |
@hurd54 done |
|
Can you write small example of your code for check your case? |
for example right now I have helper like this to map uuid into struct fields
After upgrading I will have to rewrite all places with
|
The closes example would be your If my struct use |
1 similar comment
The closes example would be your If my struct use |
Do you use native sdk or database sql code? Custom types in with native code can implement Scanner interface for override unmarshal behavior. Example for uuid case: I didn't tested the behavior of custom type with database/sql, I can do it and guide for code fix code with minimal work.
if your code use uuid.UUID with database/sql - it should be break after upgrade #1515 for native sdk uuid.UUID can scan as 'new style' uuid only, but old versions of the native SDK can't scan uuid.UUID at all. |
By plan code migration should be trivial (but if you have a lot of code - it can take fix in may places) and if you have some mistake (forget update some places) - new code stop to work (at compile time or runtime if it is impossible to runtime check) without data corruption. |
they can, as bytes array. So code is clean, you scan your struct field by field with no boilerplate code.
you don't need any helper variables to move fields from one representations to another one
we use native sdk. Unfortunately it doesn't seem to allow any custom unmarshallers |
What about implement Scanner for I can research it in details at start of next week. |
The problem discussion started at ydb-platform/ydb#9799
Summary:
The SDK was send and receive UUID with bug: sdk byte order has differences to the server byte orders. It was not detected by unit tests and read-write tests (the SDK read same UUID, which was written).
Nobody saw the problem a lot of time, because UUID can't be stored on the server until last version. Now if the sdk send UUID to the server it and read it with YQL (cast to string) or other SDK (for example python) - readed UUID has differences from written.
Fix way in SDK:
3.86.x
, where old code work as is. In the version I add additional functions - for explicit read/write UUID with old behavior and for read/write with correct format. At the point need to explicit select way for every read/write UUID (old with bug or new).3.87.x
-3.88.x
) break compatibility of old code as soon as possible: write code will be break at compile time and scan values code will be failed at runtime. All old code for work with UUID will be broken.Migration for customers:
If you didn't use UUID before migration version: use good way functions. No need to do anything.
If you used the UUID and your code broken to compile or you have runtime error "ydb: uuid storage format was broken in go SDK..." you have to do change your code.
Migration example:
v3.86 - old-style code work with bug, no new code in sdk
Old code
upgrade ydb sdk to v3.87, old code still work
Same code
v3.87 upgrade code, without upgrade the sdk
Change function
types.UUID
totypes.UUIDWithIssue1501Value
for send value and use typetypes.UUIDBytesWithIssue1501Type
for scan uuid value with old style.After the changes code continue to work without change behavior
Update code to explicit work in old style
Update SDK
Then you can upgrade the SDK without change the behavior and you have a time for data migration.
Data migration
Is is very dependency from project, purposre - rewrite uuid, stores in old style with bug to good uuid format. Which will be consistency with other SDKs and server YQL.
Change the code for work in new style - will work from v3.87 and later
During migration data for load/store good UUIDs and after migration use new-style code
New style code
The text was updated successfully, but these errors were encountered: