Databases 7 min read

Tagging GTIDs in MySQL 8.3: Format, Usage, and Experiments

This article explains MySQL 8.3’s new ability to tag GTIDs, describes the original and extended GTID formats, demonstrates how to enable and use tagged GTIDs with mysql-shell, and shows how tagged and non-tagged transactions appear in replication logs.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Tagging GTIDs in MySQL 8.3: Format, Usage, and Experiments

Abstract

MySQL 8.3, released on 2024‑01‑16, adds support for labeling Global Transaction Identifiers (GTIDs) in replication and group replication, allowing transactions to be distinguished by custom tags.

GTID Format

Original format

The original GTID format is source_id:transaction_id , where source_id identifies the source server (usually its server_uuid) and transaction_id is the sequential number of the transaction on that server.

GTIDs are globally unique across the entire replication topology.

Tagged format

The extended format is source_id:<tag>:transaction_id , where tag is an optional string up to 8 characters. Setting the system variable gtid_next='AUTOMATIC:<tag>' or gtid_next='uuid:<tag>:transaction_id' enables tagged GTIDs.

Experiment

Using mysql-shell a MySQL 8.3 instance was deployed (details omitted). The following connection parameters were used:

Parameter

Value

Host IP

10.186.58.39

Hostname

node1

Port

3333

MySQL version

8.3.0

Environment inspection

#node1
SQL > select @@hostname,@@version,@@port,@@gtid_mode,@@gtid_executed;
+------------+-----------+--------+-------------+------------------------------------------+
| @@hostname | @@version | @@port | @@gtid_mode | @@gtid_executed |
+------------+-----------+--------+-------------+------------------------------------------+
| node1      | 8.3.0     | 3333   | ON          | 
+------------+-----------+--------+-------------+------------------------------------------+

Creating a user with a tagged GTID (tag = dba):

# Create user and grant privileges, tag = dba
SQL > set gtid_next="AUTOMATIC:dba";
Query OK, 0 rows affected (0.0032 sec)

SQL > create user dba@'%' identified with mysql_native_password by 'dba';
Query OK, 0 rows affected (0.0332 sec)

SQL > select @@hostname,@@version,@@port,@@gtid_mode,@@gtid_executed;
+------------+-----------+--------+-------------+------------------------------------------------+
| @@hostname | @@version | @@port | @@gtid_mode | @@gtid_executed                                 |
+------------+-----------+--------+-------------+------------------------------------------------+
| node1      | 8.3.0     | 3333   | ON          | a45d9e72-c33b-11ee-a645-02000aba3a27:dba:1 |
+------------+-----------+--------+-------------+------------------------------------------------+

SQL > grant all privileges on *.* to dba@'%';
Query OK, 0 rows affected (0.0126 sec)

SQL > select @@hostname,@@version,@@port,@@gtid_mode,@@gtid_executed;
+------------+-----------+--------+-------------+--------------------------------------------------+
| @@hostname | @@version | @@port | @@gtid_mode | @@gtid_executed                                 |
+------------+-----------+--------+-------------+--------------------------------------------------+
| node1      | 8.3.0     | 3333   | ON          | a45d9e72-c33b-11ee-a645-02000aba3a27:dba:1-2 |
+------------+-----------+--------+-------------+--------------------------------------------------+

Switching back to the original GTID generation mode and performing business operations (create database and table):

# Create database and table
SQL > set gtid_next="AUTOMATIC";
Query OK, 0 rows affected (0.0032 sec)

SQL > create database lfq;
Query OK, 1 row affected (0.0182 sec)

SQL > select @@hostname,@@version,@@port,@@gtid_mode,@@gtid_executed;
+------------+-----------+--------+-------------+--------------------------------------------------+
| @@hostname | @@version | @@port | @@gtid_mode | @@gtid_executed                                 |
+------------+-----------+--------+-------------+--------------------------------------------------+
| node1      | 8.3.0     | 3333   | ON          | a45d9e72-c33b-11ee-a645-02000aba3a27:1:dba:1-2 |
+------------+-----------+--------+-------------+--------------------------------------------------+

SQL > create table lfq.t1(c1 int primary key, c2 varchar(10));
Query OK, 0 rows affected (0.0685 sec)

SQL > select @@hostname,@@version,@@port,@@gtid_mode,@@gtid_executed;
+------------+-----------+--------+-------------+--------------------------------------------------+
| @@hostname | @@version | @@port | @@gtid_mode | @@gtid_executed                                 |
+------------+-----------+--------+-------------+--------------------------------------------------+
| node1      | 8.3.0     | 3333   | ON          | a45d9e72-c33b-11ee-a645-02000aba3a27:1-2:dba:1-2 |
+------------+-----------+--------+-------------+--------------------------------------------------+
Summary: The GTIDs a45d9e72-c33b-11ee-a645-02000aba3a27:dba:1 and a45d9e72-c33b-11ee-a645-02000aba3a27:dba:2 correspond to the tagged user‑creation transactions, while a45d9e72-c33b-11ee-a645-02000aba3a27:1-2 and a45d9e72-c33b-11ee-a645-02000aba3a27:2 correspond to the non‑tagged business operations.
SQLDatabaseMySQLReplicationTaggingGTID
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.