[MDEV-31926] UUID v7 are compared incorrectly Created: 2023-08-15 Updated: 2023-12-19 Resolved: 2023-10-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types |
| Affects Version/s: | 10.9.8, 10.10.6, 10.11.5, 11.0.3 |
| Fix Version/s: | 10.10.7, 10.11.6, 11.0.4, 11.1.3, 11.2.2 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sergei Golubchik | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
because it compares segments backwards independently from the version:
|
| Comments |
| Comment by Evgenii [ 2023-08-15 ] | ||||||||||||
|
@serg Do I understand correctly that you release new versions every few months and this fix will not get into version 10.11.5, but will appear or example, in version 10.11.6? Or have there been cases when, after a few days / weeks, an already released version was fixed?) | ||||||||||||
| Comment by Sergei Golubchik [ 2023-08-15 ] | ||||||||||||
|
There have been cases. If a released version is basically impossible to use, like, some bug in packaging that our testing missed. But luckily it doesn't happen very often. Normally, indeed, this bug won't be fixed until the next release about 3 months from now. | ||||||||||||
| Comment by Evgenii [ 2023-10-10 ] | ||||||||||||
|
@serg Good day, saw the status of release 10.11.6 scheduled for 2023-10-26, will this bug fix be included in this release?) | ||||||||||||
| Comment by Sergei Golubchik [ 2023-10-16 ] | ||||||||||||
|
I cannot say for sure yet. There are few bugs I have to fix first before getting to this one. I hope it will be, though | ||||||||||||
| Comment by Evgenii [ 2023-10-25 ] | ||||||||||||
|
@serg Maybe you can delay the release a little so that this bugfix is included in it? Waiting another 3 months for the next release would be a disaster | ||||||||||||
| Comment by Sergei Golubchik [ 2023-10-27 ] | ||||||||||||
|
xpun, I've trying to understand how to define a comparison of two UUID values, how to determine what is "correct". In your test case you compare
and get different results. But on itself it doesn't mean the comparison is incorrect. Compare with
In other words, comparing values as strings and using the native type comparison can produce different results, it's not a bug. How can I see that the comparison is incorrect? | ||||||||||||
| Comment by Evgenii [ 2023-10-27 ] | ||||||||||||
|
@serg For example, I'm creating a table with "messages (id, user_id). Both columns has "uuid" type. First I want to retrive 20 latest messages. Then the next 20, and so on.
. Next query:
In version 10.11.4, when using uuid v1, it worked like that. I expect uuid v7 to behave the same as uuid v1. | ||||||||||||
| Comment by Evgenii [ 2023-10-27 ] | ||||||||||||
|
Uuid v7 was invented to monotonically increase as a replacement for regular autoincrement. And it's expected to sort essentially like a number. Otherwise if I need a simple random string I can generate uuid v4. Uuid v1 - also monotonically increasing, but it is more prone to collisions | ||||||||||||
| Comment by Sergei Golubchik [ 2023-10-28 ] | ||||||||||||
|
It seems you're right, the latest UUID draft (from 20 October 2023) says
Old draft said the same. That is, indeed, concat(uuid) and uuid should sort the same way, at least for v6 and v7. By the way, note that UUIDv1 — as generated inside MariaDB — isn't prone to collisions, MariaDB guarantees that all UUID() values are unique, even if requested within the same 100 ns time slot. | ||||||||||||
| Comment by Alexander Barkov [ 2023-10-30 ] | ||||||||||||
|
serg,
. .. which part of the above two expressions checks what. |