GTID is better than old filename and fileoffset to manage replication explicitly. MySQL and MariaDB have different formats of GTID. Here shows the GTID of MySQL.
Every time the master makes an update it creates an GTID event to the binlog and next do the actual transaction. A slave sends the master a range of GTID that has been executed (GTID_EXECUTED) and the master thread sends back the slave all the unexecuted transactions. The IO thread of the slave saves the transactions in the relay log and the SQL thread applies the master trasactions on the slave.
The slave increases GTID_NEXT by 1 when it executes a transaction normally. However in some cases, we want to modify the value manually. A typical case is to skip a master transaction in the slave. To do that, we assign the GTID_NEXT session variable the failed transaction number and inject an empty transaction like the above picture. By doing this, GTID_EXECUTED of the slave jumps to a wanted number.
Top comments (0)