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
UUID partition change #4914
UUID partition change #4914
Changes from all commits
c28cdda
462b9cc
20f0dc5
0d02488
48520a1
000ea72
2a27781
efe1c6f
8eb7df2
2c71696
4f4c564
0fd79a8
a3b336c
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'm not sure about the implementation.
We know that the UUID generator generates UUID for the same partition, and the partition is determined by the block ID and transaction index.
In other words, given a UUID Generator, if we keep calling
GenerateUUID
, the returned value always the same byte at the partition byte position, which is the 3rd byte.However, L201 takes the stored uuid value and add
1
to it:This works if partition is the 1st byte, but won't work if partition is 3rd byte.
See this case: if now the UUID for partition 2 is:
3298534883327
(hex:00 00 02 FF FF FF FF FF
)Then calling
GenerateUUID()
again, will callsetUint56(value + 1)
, which becomes00 00 03 00 00 00 00 00
, which would not incrementC6
, and causing the counter to go back to 0 again.We need to have a test case, for a UUID generator for partition 2 and it's value is
00 00 02 FF FF FF FF FF
, the next two UUIDs should be00 01 02 00 00 00 00 00
, and00 01 02 00 00 00 00 01
.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.
What happens is that we first call
generator.getUint64()
which gets the stored counter for that partition (00 00 00 FF FF FF FF FF
). then stores it back as incremented by 1generator.setUint56(value + 1)
( 00 00 01 00 00 00 00 00). Only after this is the value cut up and the partition bytes inserted.value:
00 00 00 FF FF FF FF FF
partition:
02
and the next one:
value:
00 00 01 00 00 00 00 00
partition:
02
I do agree that a test for this continuation would be great!
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.
@zhangchiqing
actually problem is naming of the function, I didn't want to touch that. Actually
getuint64
is just returning the counter ( without partition byte )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.
@bluesign could you at least add this test case? Just want to make sure we have test case covering 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.
sure, of course, I missed that part of the 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.
Oh, I know where I got confused. I thought the stored register value contains the partition and the counter, but actually it is just the counter. The register ID contains the partition already.
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 naming of the functions are confusing,
setUint56
andgetUint64
makes you feel like you are setting 56 bits of 64 bit int, and then getting it as 64 bit with partition.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.
exactly