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
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.
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.