Replication Protocol
Understand the replication protocol. This section details how primary and replica servers communicate, exchanging binary log events to ensure data consistency and enable high availability.
This section provides an overview of the various events recorded in the binary log, which are the core units of replication data transmission.
Every binary log event starts with a standardized header containing metadata such as the timestamp, event type, server ID, and event size.
Describes the continuous packet stream format used to transmit binary log events from the primary server to the replica over the network.
Explains the handshake and acknowledgement process for semi-synchronous replication, ensuring data is committed on at least one replica.
Details the initialization phase where a replica connects to the primary, authenticates, sends capabilities, and registers for updates.
This event accompanies row-based events to provide the original SQL query text, which is useful for auditing and debugging replication.
Used during LOAD DATA INFILE operations, this event marks the beginning of the data load and contains the initial query information.
A marker event indicating a checkpoint in the binary log, used to ensure consistency and safe rotation of log files.
This command is sent by a replica to the primary server to request the start of the binary log event stream from a specific file and position.
This command is used by a replica to register its details, such as server ID, hostname, and port, with the primary server.
This event is used for LOAD DATA INFILE operations, managing the execution phase similar to a QUERY_EVENT but with extra static fields for file handling.
A synthetic event sent by the master after the initial handshake to inform the replica of its current GTID state, it is not written to the binary log.
An artificial event sent to the replica to indicate the name of the binary log file on the master, ensuring the replica knows which file is being read.
This descriptor event appears at the start of every binary log file, defining the server version, binlog version, and header lengths for all event types.
The GTID_EVENT marks the start of a new transaction event group, associating it with a Global Transaction ID (GTID) and providing commit flags.
Logged during binlog rotation or checkpoints, this event lists the GTIDs present in the binary log to help replicas determine their replication state.
A heartbeat event sent over the network by the master when there are no binlog events, ensuring the replica knows the connection is still active.
This event records integer values for auto-increment columns or the LAST_INSERT_ID function, ensuring that these values are replicated deterministically.
The QUERY_EVENT records text-based SQL statements for statement-based replication, capturing the query string and execution context like the default database.
The RAND_EVENT records the two seed values used for the random number generator, ensuring that calls to the RAND() function produce identical results on replicas.
The ROTATE_EVENT indicates a log rotation, specifying the name of the next binary log file and the position where writing will continue.
These events record row-level changes (WRITE, UPDATE, DELETE) for replication, with versions supporting different column counts and compression.
This event marks the beginning of encrypted data in the binary log, defining the encryption scheme and key version for subsequent events.
The STOP_EVENT is written to the binary log when the server shuts down, serving as a marker for a clean stop.
This event provides a mapping between a table ID and its table definition, preceding row events to interpret the row data correctly.
The USER_VAR_EVENT logs the value of a user-defined variable, ensuring that statements using variables replicate consistently.
This event records the preparation phase of an XA transaction, storing the XID to support two-phase commit and recovery.
The XID_EVENT signifies the commit of a transaction, containing the transaction ID (XID) to ensure atomicity across replication.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

