MDEV-32637 Implement native UUID7 function#3093
MDEV-32637 Implement native UUID7 function#3093StefanoPetrilli wants to merge 2 commits intoMariaDB:11.6from
Conversation
b34c8c2 to
155ab93
Compare
grooverdan
left a comment
There was a problem hiding this comment.
Well done on the depth of initial implementation.
155ab93 to
025fc56
Compare
2d216a3 to
e3496f2
Compare
e3496f2 to
46bef2a
Compare
dlenski
left a comment
There was a problem hiding this comment.
Other than the issue of breaking time-sortability if you build up too much "borrowed time" and then restart the server (CREATE new_table AS SELECT UUID7(), T.* FROM table_with_1_million_rows T), this looks really good to me. 🙌
ba470e7 to
344bb52
Compare
dlenski
left a comment
There was a problem hiding this comment.
Other than my small remaining nitpick about the name(s) of the constant(s), this looks fantastic. Approving! 🙌
LinuxJedi
left a comment
There was a problem hiding this comment.
Great work! A few minor things to fix and I think we are there.
Later on (not for this Jira ticket or PR) we could add a test for this to check that the UUID timestamp is within a tolerable range of a timestamp (+/- 2 hours?) in the same column by creating a new function to extract the UUID timestamp. If we do it range based then we won't need to worry about monotonic / DST quite as much.
db143ce to
6bfbb8c
Compare
c1cc665 to
96be6e7
Compare
|
@LinuxJedi wrote:
Since it's based on Unix-epoch timestamp, shouldn't need to worry about DST 😅 |
96be6e7 to
b923baf
Compare
b923baf to
5dc0e30
Compare
vuvova
left a comment
There was a problem hiding this comment.
UUID code is pretty good, just doesn't need to reside in mysys.
The function could be greatly simplified by using the approach from https://github.com/MariaDB/server/tree/bb-11.5-bar-MDEV-11339 (after rebasing this PR on top of that branch).
@StefanoPetrilli , I know you're busy now. There's no hurry, you can get back to it after GSoC. Just, please, if you decide not to continue with the PR at all — add a comment and say so.
5dc0e30 to
3d65dd8
Compare
|
you've marked all my comments as resolved without actually changing anything. how comes? |
3d65dd8 to
5545c0d
Compare
Hey @vuvova, now you should be able to see the changes, I messed up while pushing. |
|
I still don't see any changes 🤷♂️ |
|
Thanks. I've cherry-picked both UUIDv4 and UUIDv7 code into bb-11.7-MDEV-33710-uuid branch to be tested and merged into main |
|
pushed into 11.7, thanks! |
Description
MariaDB provides the UUID method that generates UUID v1, however, UUID v1 generates non-linear UUIDS that will spread data across different linear partitions based on key or hash.
The new UUID7 (https://uuid7.com/) will guarantee that continuous records are time-sorted and a good collision resistance.
The main advantage of the UUID7 function is that it will allow MariaDB to avoid the limitation of using a unique combined primary key for time series records, where a unique ID and a date are required to create key/hash partitions. With UUID7 is possible to only use the key as ID and time reference.
Release Notes
Adds the function:
UUIDv7(): returns a UUIDv7How can this PR be tested?
This PR adds automatic tests that partially test the new functions.
I am not aware of an easy way to change the time retrieved by
my_hrtime(), hence, I could not write automatic tests to verify that the UUIDs generated are monotonic.I am open to suggestions on how to accomplish that.
Basing the PR against the correct MariaDB version
PR quality check