Understanding MariaDB GTID  Implementation.

MariaDB global transaction ID, or GTID for short, consists of three numbers separated with dashes ‘-‘. For example:


  • The first number 0 is the domain ID, which is specific for global transaction ID. It is a 32-bit unsigned integer.
  • The second number is the server ID, the same as is also used in old-style replication. It is a 32-bit unsigned integer.
  • The third number is the sequence number. This is a 64-bit unsigned integer that is monotonically increasing for each new event group logged into the binlog.

GTIDs are defined in the server sql/rpl_gtid.xx source tree as follows

    struct rpl_gtid
uint32 domain_id;
uint32 server_id;
uint64 seq_no;


The server ID is set to the server ID of the server where the event group is first logged into the binlog. The sequence number is increased on a server for every event group logged. Since server IDs must be unique for every server, this makes the (server_id, sequence_number) pair, and hence the whole GTID, globally unique.

Using a 64-bit number provides a wide range that there should be no risk of it overflowing in the foreseeable future.

MHA Implementation.

This Week, I have studied how the GTID is Implemented in the Server code and what each number in a GTID represents.

A Github project HERE  has been created where I will be pushing my code.

I have also set up 5 MariaDB instances on OS X for testing following this blogpost.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s