Description:
According to the documentation, GTID tags cannot be longer than 8 characters. However, in reality, you can set the tag up to 42 characters long.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.7 MySQL Community Server - GPL
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql [localhost:8407] {msandbox} (world) > SET gtid_next='AUTOMATIC:thisislongerthan10_chars';
Query OK, 0 rows affected (0.00 sec)
mysql [localhost:8407] {msandbox} (world) > CREATE TABLE authors (id int primary key, name varchar(20));
Query OK, 0 rows affected (0.03 sec)
mysql [localhost:8407] {msandbox} (world) > INSERT INTO authors VALUES (1, 'Alice');
Query OK, 1 row affected (0.01 sec)
mysql [localhost:8407] {msandbox} (world) > SHOW BINLOG EVENTS IN 'binlog.000002';
+---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+
| binlog.000002 | 4 | Format_desc | 1 | 127 | Server ver: 8.4.7, Binlog ver: 4 |
| binlog.000002 | 127 | Previous_gtids | 1 | 158 | |
| binlog.000002 | 158 | Gtid_tagged_log_event | 1 | 253 | SET @@SESSION.GTID_NEXT= '00008407-0000-0000-0000-000000008407:thisislongerthan10_chars:1' |
| binlog.000002 | 253 | Query | 1 | 402 | use `world`; CREATE TABLE authors (id int primary key, name varchar(20)) /* xid=20 */ |
| binlog.000002 | 402 | Gtid_tagged_log_event | 1 | 497 | SET @@SESSION.GTID_NEXT= '00008407-0000-0000-0000-000000008407:thisislongerthan10_chars:2' |
| binlog.000002 | 497 | Query | 1 | 573 | BEGIN |
| binlog.000002 | 573 | Table_map | 1 | 635 | table_id: 103 (world.authors) |
| binlog.000002 | 635 | Write_rows | 1 | 681 | table_id: 103 flags: STMT_END_F |
| binlog.000002 | 681 | Xid | 1 | 712 | COMMIT /* xid=21 */ |
+---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+
9 rows in set (0.00 sec)
mmysql [localhost:8407] {msandbox} (world) > SET gtid_next = 'AUTOMATIC:this_is_a_very_long_gtid_tag_1234';
ERROR 1774 (HY000): Malformed GTID specification 'AUTOMATIC:this_is_a_very_long_gtid_tag_1234'.
mysql [localhost:8407] {msandbox} (world) > SET gtid_next = 'AUTOMATIC:this_is_a_very_long_gtid_tag_123';
Query OK, 0 rows affected (0.00 sec)
mysql [localhost:8407] {msandbox} (world) > SELECT LENGTH(@@gtid_next);
+---------------------+
| LENGTH(@@gtid_next) |
+---------------------+
| 42 |
+---------------------+
1 row in set (0.00 sec)
mysql [localhost:8407] {msandbox} (world) > SELECT @@gtid_next;
+--------------------------------------------+
| @@gtid_next |
+--------------------------------------------+
| AUTOMATIC:this_is_a_very_long_gtid_tag_123 |
+--------------------------------------------+
1 row in set (0.00 sec)
Ref: https://dev.mysql.com/doc/refman/8.4/en/replication-options-gtids.html#sysvar_gtid_next
How to repeat:
See above. Simply set the tag longer than 8 characters, in violation of the docs specification.
Suggested fix:
Enforce constraint as stated in docs, or update docs to match actual constraint.
Source code indicates tags can be up to 32 characters long.
https://github.com/mysql/mysql-server/blob/8.4/libs/mysql/gtid/gtid_constants.h#L43-L44
mysql [localhost:8407] {msandbox} (world) > SELECT @@gtid_next, LENGTH('this_is_a_very_long_gtid_tag_123');
+--------------------------------------------+--------------------------------------------+
| @@gtid_next | LENGTH('this_is_a_very_long_gtid_tag_123') |
+--------------------------------------------+--------------------------------------------+
| AUTOMATIC:this_is_a_very_long_gtid_tag_123 | 32 |
+--------------------------------------------+--------------------------------------------+
1 row in set (0.00 sec)
Description: According to the documentation, GTID tags cannot be longer than 8 characters. However, in reality, you can set the tag up to 42 characters long. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.4.7 MySQL Community Server - GPL Copyright (c) 2000, 2025, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql [localhost:8407] {msandbox} (world) > SET gtid_next='AUTOMATIC:thisislongerthan10_chars'; Query OK, 0 rows affected (0.00 sec) mysql [localhost:8407] {msandbox} (world) > CREATE TABLE authors (id int primary key, name varchar(20)); Query OK, 0 rows affected (0.03 sec) mysql [localhost:8407] {msandbox} (world) > INSERT INTO authors VALUES (1, 'Alice'); Query OK, 1 row affected (0.01 sec) mysql [localhost:8407] {msandbox} (world) > SHOW BINLOG EVENTS IN 'binlog.000002'; +---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+ | binlog.000002 | 4 | Format_desc | 1 | 127 | Server ver: 8.4.7, Binlog ver: 4 | | binlog.000002 | 127 | Previous_gtids | 1 | 158 | | | binlog.000002 | 158 | Gtid_tagged_log_event | 1 | 253 | SET @@SESSION.GTID_NEXT= '00008407-0000-0000-0000-000000008407:thisislongerthan10_chars:1' | | binlog.000002 | 253 | Query | 1 | 402 | use `world`; CREATE TABLE authors (id int primary key, name varchar(20)) /* xid=20 */ | | binlog.000002 | 402 | Gtid_tagged_log_event | 1 | 497 | SET @@SESSION.GTID_NEXT= '00008407-0000-0000-0000-000000008407:thisislongerthan10_chars:2' | | binlog.000002 | 497 | Query | 1 | 573 | BEGIN | | binlog.000002 | 573 | Table_map | 1 | 635 | table_id: 103 (world.authors) | | binlog.000002 | 635 | Write_rows | 1 | 681 | table_id: 103 flags: STMT_END_F | | binlog.000002 | 681 | Xid | 1 | 712 | COMMIT /* xid=21 */ | +---------------+-----+-----------------------+-----------+-------------+--------------------------------------------------------------------------------------------+ 9 rows in set (0.00 sec) mmysql [localhost:8407] {msandbox} (world) > SET gtid_next = 'AUTOMATIC:this_is_a_very_long_gtid_tag_1234'; ERROR 1774 (HY000): Malformed GTID specification 'AUTOMATIC:this_is_a_very_long_gtid_tag_1234'. mysql [localhost:8407] {msandbox} (world) > SET gtid_next = 'AUTOMATIC:this_is_a_very_long_gtid_tag_123'; Query OK, 0 rows affected (0.00 sec) mysql [localhost:8407] {msandbox} (world) > SELECT LENGTH(@@gtid_next); +---------------------+ | LENGTH(@@gtid_next) | +---------------------+ | 42 | +---------------------+ 1 row in set (0.00 sec) mysql [localhost:8407] {msandbox} (world) > SELECT @@gtid_next; +--------------------------------------------+ | @@gtid_next | +--------------------------------------------+ | AUTOMATIC:this_is_a_very_long_gtid_tag_123 | +--------------------------------------------+ 1 row in set (0.00 sec) Ref: https://dev.mysql.com/doc/refman/8.4/en/replication-options-gtids.html#sysvar_gtid_next How to repeat: See above. Simply set the tag longer than 8 characters, in violation of the docs specification. Suggested fix: Enforce constraint as stated in docs, or update docs to match actual constraint. Source code indicates tags can be up to 32 characters long. https://github.com/mysql/mysql-server/blob/8.4/libs/mysql/gtid/gtid_constants.h#L43-L44 mysql [localhost:8407] {msandbox} (world) > SELECT @@gtid_next, LENGTH('this_is_a_very_long_gtid_tag_123'); +--------------------------------------------+--------------------------------------------+ | @@gtid_next | LENGTH('this_is_a_very_long_gtid_tag_123') | +--------------------------------------------+--------------------------------------------+ | AUTOMATIC:this_is_a_very_long_gtid_tag_123 | 32 | +--------------------------------------------+--------------------------------------------+ 1 row in set (0.00 sec)