DEV Community

drevispas
drevispas

Posted on

3

Too direct introduction to MySQL GTID

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

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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay