In MySQL 5.5 replication can optionally be made semi-synchronous instead of the traditionally asynchronous replication.
The clients COMMIT (or in auto-commit mode the current statement) waits until _one_ slave acknowledged that it received (not neccesarilly executed) the transaction or a timeout is reached. In case the timeout is reached, semi-sync replication is disabled.
See http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html for more.
To see of the master supports semi-sync replication run:
SHOW VARIABLES LIKE 'rpl_semi_sync_master_enabled';
The slave requests semi-sync replication by sending:
SET @rpl_semi_sync_slave = 1;
which the master either responds with a
OK_Packet
if it supports semi-sync replication or with
ERR_Packet
if it doesn't.
After the 00 OK-byte of a
binlog network
stream 2 bytes get added before the normal
Binlog Event continues.:
1 [ef] semi-sync indicator 1 semi-sync flags
If the SEMI_SYNC_ACK_REQ flag is set the master waits for a Semi Sync ACK packet from the slave before it sends the next event.
Each Semi Sync Binlog Event with the SEMI_SYNC_ACK_REQ flag set the slave has to acknowledge with Semi-Sync ACK packet:
SEMI_SYNC_ACK
payload:
1 [ef]
8 log position
string log filename
which the master acknowledges with a
OK_Packet
or a
ERR_Packet.
