Skip to content

adding @@server_uuid system variable#2302

Merged
jycor merged 3 commits intomainfrom
james/server-uuid
Jan 31, 2024
Merged

adding @@server_uuid system variable#2302
jycor merged 3 commits intomainfrom
james/server-uuid

Conversation

@jycor
Copy link
Copy Markdown
Contributor

@jycor jycor commented Jan 30, 2024

This PR adds support for the @@server_uuid system variable.
However, this just generates a random UUID on server start, and does not persist it to a file.

MySQL Docs:
https://dev.mysql.com/doc/refman/8.0/en/replication-options.html#sysvar_server_uuid

Fixes dolthub/dolt#7431

Copy link
Copy Markdown
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one code comment on matching the sys var type from MySQL closer.

It is a little odd that the value of @@server_uuid will change when the sql-server restarts, but I think this is still a good step forward and should resolve the immediate customer issue. Persisted system variables will be stored to the ~/.dolt directory when they are set by a user and all servers on the same host will use that same persisted value, but I don't think we'll automatically write that default value to ~/.dolt.

There may be some interaction with binlog replication, since the UUID is used as an identifier for the host in some cases. We use @@server_id in our code where Dolt works as a replica for a MySQL server. From a quick look, I think @@server_uuid may be more important on the source MySQL server, since the GTIDs for that host include the UUID, so since we only implement the replica side of replication currently, we may not run into any issues right now.

So... we may end up needing to revisit this if we hit issues with replication, but I think this looks like a good step forward.

Scope: sql.SystemVariableScope_Persist,
Dynamic: false,
SetVarHintApplies: false,
Type: types.Blob,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like MySQL actually returns this as a string, and not as binary data:

mysql -e "select @@server_uuid" --column-type-info -uroot 
Field   1:  `@@server_uuid`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb4_0900_ai_ci (255)
Length:     87380
Max_length: 36
Decimals:   31
Flags:      

+--------------------------------------+
| @@server_uuid                        |
+--------------------------------------+
| 85716002-48f5-11ee-bff9-e71bd3cf9371 |
+--------------------------------------+

@jycor jycor merged commit d0e3ceb into main Jan 31, 2024
@jycor jycor deleted the james/server-uuid branch January 31, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@@server_uuid generated by mysqlsh. Dolt does not support that system variable.

2 participants