← Lessons

quiz vs the machine

Gold1470

Databases

The GTID Replication

How global transaction ids simplify tracking and failover in MySQL replication.

6 min read · core · beat Gold to climb

A global id per transaction

Classic replication tracks position by binlog file name and offset, which differ on every server and make failover fragile. Global Transaction Identifiers, or GTIDs, give each committed transaction a unique id of the form source uuid plus a sequence number, identical across the whole topology.

Why it helps

  • A replica records the set of GTIDs it has applied, so it knows exactly which transactions it still needs.
  • On failover you point a replica at a new primary and it requests only the missing GTIDs, with no manual file and offset arithmetic.
  • Each transaction is applied at most once, since a GTID already present is skipped.

Auto positioning

With GTID enabled, replicas use auto positioning: the replica sends its applied GTID set and the primary streams whatever is missing. This replaces the brittle CHANGE MASTER TO with explicit log positions.

Constraints

GTID mode requires that every transaction be logged and imposes some restrictions, such as limits on mixing transactional and nontransactional changes, but modern deployments treat it as the default for manageable replication.

Key idea

GTIDs tag each transaction with a globally unique id so replicas track an applied set and use auto positioning, making failover and consistency far simpler than file and offset based replication.

Check yourself

Answer to earn rating on the learn ladder.

1. What problem do GTIDs solve over file and offset replication?

2. What does auto positioning let a replica do?