[MDEV-6445] UUID column type addition for distributed systems Created: 2014-07-15 Updated: 2020-05-05 Resolved: 2016-08-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Fix Version/s: | 10.2.1 |
| Type: | Task | Priority: | Minor |
| Reporter: | Anders Karlsson | Assignee: | Michael Widenius |
| Resolution: | Fixed | Votes: | 5 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
Feature request:
The two last of these attributes are no longer always true. In addition, to keep the value unique one has to resort to using auto_increment_increment and auto_increment_offset, which will break the last of the assumptions above and when using a distributed system, classic Replication or Galera, then even the second one breaks. But these settings are still necessary to ensure uniqueness in a distributed system. So the idea then is to, in addition to AUTO_INCREMENT I suggest we add a UUID column attribute. As for an INSERT, this would be the same as using UUID() for the column in the insert statement, but having this as a column attribute has several advantages. Compared to AUTO_INCREMENT there are also many advantages, such as avoiding at AUTO_INCREMENT mutex locks. In addition, having this as a column attribute would be a declarative, so the schema documents the column attribute properly. To make this work, we need to add a mysql_last_uuid() function and a LAST_UUID SQL functioon added. I could see this having some additional features, such as:
A drawback of this schema compared to AUTO_INCREMENT is that this will consume some more space in the specified column, but 16 bytes (8 bytes of we use UUID_SHORT) when the dashes are removed isn't so bad. The advantages not having to deal with the auto_increment_xxx settings, in particular when new nodes are added to the cluster, should outweigh this, |
| Comments |
| Comment by Anders Karlsson [ 2014-07-16 ] |
|
An added benefit of using a UUID instead of some AUTO_INCREMENT is that in a distributed system, using Galera or Replication, data can be migrated between nodes and there is no data that ties or identifies a row to a specific server. |
| Comment by Sergei Golubchik [ 2014-07-21 ] |
|
This looks like a duplicate of |
| Comment by Anders Karlsson [ 2014-07-21 ] |
|
There is an overlap, but not a duplicate. What I suggest though is that automatic generation of a UUID is added and that semantics are such that only a proper UUID can be inserted and that it is always generated, so in the case of an INSERT and UPDATE, NULL always has to be passed if the value is to be updated. To support this, the proposed SQL and API functions for retrieving the last generated UUID has to be added. |
| Comment by Sergei Golubchik [ 2014-07-22 ] |
|
Indeed, thanks for the clarification |
| Comment by Sergei Golubchik [ 2016-07-28 ] |
|
Now, when one can specify DEFAULT UUID() for any column is this feature still necessary? |
| Comment by VAROQUI Stephane [ 2016-07-28 ] |
|
Hello Sergei, Is the value for last_insert_id , the PK or UNIQUE KEY default or always auto increment ? /svar |
| Comment by Sergei Golubchik [ 2016-07-28 ] |
|
last_insert_id is for auto increment only. INSERT ... RETURNING is a separate task |
| Comment by Daniël van Eeden [ 2016-07-28 ] |
|
A column type could still be a good idea:
|
| Comment by VAROQUI Stephane [ 2016-07-28 ] |
|
dveeden that looks like existing UUID_SHORT and it should work the same ! serg without a way to fetch what was inserted it make this feature less attractive .The requirement that the field is facing today, is sometime to get read of auto increment. I appreciate the good step forward still , but will not make some of our clients move to 10.2. I will continue living with ugly triggers and ROW base login. Can the DEFAULT overwrite |
| Comment by Sergei Golubchik [ 2016-07-28 ] |
|
dveeden, UUID column type is stephane@skysql.com, returning the last generated uuid value was not part of this issue. And DEFAULT UUID() does not solve it either. It's a completely separate issue that does not affect whether this |
| Comment by VAROQUI Stephane [ 2016-07-28 ] |
|
Sergei i'm quoting 2 sentences from this issue
So may be this issue closing should be blocked by some missing additional task ? |
| Comment by Sergei Golubchik [ 2016-07-28 ] |
|
let's consider this part of INSERT ... RETURNING task |
| Comment by VAROQUI Stephane [ 2016-07-28 ] |
|
Great news thanks |