SyntaxStudy
Sign Up
MySQL Semi-Synchronous Replication
MySQL Advanced 4 min read

Semi-Synchronous Replication

Semi-Sync Replication

Standard replication is asynchronous — primary commits before replica confirms. Semi-sync waits for at least one replica to acknowledge before committing.

Example
-- Install semi-sync plugins
INSTALL PLUGIN rpl_semi_sync_source SONAME "semisync_source.so";
INSTALL PLUGIN rpl_semi_sync_replica SONAME "semisync_replica.so";
-- Enable on primary:
SET GLOBAL rpl_semi_sync_source_enabled = 1;
SET GLOBAL rpl_semi_sync_source_timeout = 1000;  -- 1s timeout, fallback to async
-- Enable on replica:
SET GLOBAL rpl_semi_sync_replica_enabled = 1;
-- Monitor:
SHOW STATUS LIKE "Rpl_semi_sync%";
Pro Tip

Semi-sync reduces data loss on primary failure at the cost of slightly higher write latency.