server
server copied to clipboard
MDEV-32637 Implement native UUID7 function
- [x] The Jira issue number for this PR is: MDEV-32637
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 UUIDv7
How 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
- [x] This is a new feature and the PR is based against the latest MariaDB development branch.
- [ ] This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.
PR quality check
- [x] I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
- [x] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.
@LinuxJedi wrote:
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.
Since it's based on Unix-epoch timestamp, shouldn't need to worry about DST :sweat_smile:
you've marked all my comments as resolved without actually changing anything. how comes?
you've marked all my comments as resolved without actually changing anything. how comes?
Hey @vuvova, now you should be able to see the changes, I messed up while pushing.
I still don't see any changes :man_shrugging:
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