MySQL Group Replication is the built-in way to run MySQL as a self-healing cluster: members agree on every transaction through a Paxos-based group protocol, a failed primary is replaced automatically, and no external tool decides who is in charge. InnoDB Cluster is the same engine packaged with MySQL Shell for administration and MySQL Router for client routing.
It works well, but it is less forgiving than classic asynchronous replication. Big transactions, slow networks and tables without primary keys that were harmless before now cause rollbacks, expelled members or a throttled primary. This guide covers what you need to know before you put it in front of production traffic.
What you are actually getting
- Single-primary by default.
group_replication_single_primary_modedefaults toON: one member takes writes, the others are read-only secondaries, and a new primary is elected when it fails (Group Replication variables). Multi-primary mode exists, but it has extra limitations: no cascading foreign keys, noSERIALIZABLE, and concurrent DDL and DML on the same object from different members is not supported (limitations). Unless you have a very specific reason, stay single-primary. - Agreement on order, not instant apply. A commit needs the group to agree, but secondaries apply the transaction afterwards. With the old
EVENTUALlevel, reads on a secondary, or on a freshly elected primary, can return outdated values. - Majority or nothing. A group of
n = 2f + 1members toleratesffailures: 3 members survive 1, 5 survive 2. Four members still survive only one, so even sizes buy you nothing (fault tolerance). The maximum group size is 9.
Requirements that bite on existing databases
A fresh install meets most requirements out of the box. An application database that grew for ten years usually does not (Group Replication requirements):
- InnoDB only. Other engines, including
MEMORY, can cause errors. Convert them and block new ones withdisabled_storage_engines. - Every table needs a primary key or a non-null unique key. Group Replication uses it to detect which rows each transaction touched. Find the offenders before anything else:
-- Tables without a primary key block Group Replication SELECT t.table_schema, t.table_name FROM information_schema.tables t LEFT JOIN information_schema.table_constraints c ON c.table_schema = t.table_schema AND c.table_name = t.table_name AND c.constraint_type = 'PRIMARY KEY' WHERE t.table_type = 'BASE TABLE' AND c.constraint_name IS NULL AND t.table_schema NOT IN ('mysql', 'sys', 'information_schema', 'performance_schema'); - GTIDs on.
gtid_mode=ONandenforce_gtid_consistency=ONare not the defaults. On an existing replication setup, switching GTIDs on is its own small migration. - Same
lower_case_table_namesanddefault_table_encryptionon every member. - No global replication filters. Filtering on some members would break agreement.
[mysqld]
server_id = 1 # unique per member
gtid_mode = ON # not the default
enforce_gtid_consistency = ON # not the default
disabled_storage_engines = "MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
# binlog, log_replica_updates and ROW format are already defaults in 8.4
In MySQL 8.4 binary logging, log_replica_updates and row-based logging are already on by default. The multithreaded applier is also on by default with 4 workers, and it requires replica_preserve_commit_order=ON.
Choose the consistency level on purpose
In 8.4 the default group_replication_consistency is BEFORE_ON_PRIMARY_FAILOVER: after a failover, new transactions on the new primary wait until it has applied the backlog from the old one, so clients do not read old values right after a switch (consistency guarantees). The cost is a pause during failover that grows with the backlog. Other levels:
EVENTUAL: nothing waits; fastest, but stale reads are possible on secondaries and after failover.BEFORE: a transaction waits until all preceding transactions are applied locally. Good for a session that must read its own writes from a secondary.AFTER: a read/write transaction waits until its changes are applied on all other members. Useful for read-mostly groups, expensive for write-heavy ones.BEFORE_AND_AFTER: both, with the highest latency.
The variable can be set per session, so keep the global default and raise it only for the code paths that need it.
Defaults worth changing
Out of the box, a member that ends up in a minority after a network partition waits forever: group_replication_unreachable_majority_timeout defaults to 0. It cannot commit anything, so your data is safe, but clients still connected to it hang. With a finite timeout the failure becomes visible: when it elapses, pending transactions on the minority are rolled back, the member moves to ERROR, tries to rejoin in super read only mode, and if that fails follows group_replication_exit_state_action (default OFFLINE_MODE):
-- A member cut off in a minority gives up after 30 s
SET PERSIST group_replication_unreachable_majority_timeout = 30;
-- after failed rejoin attempts it follows this action (already the default)
SET PERSIST group_replication_exit_state_action = 'OFFLINE_MODE';
A suspected member is expelled 5 seconds after the initial 5-second detection period by default (group_replication_member_expel_timeout), and it tries to rejoin 3 times (group_replication_autorejoin_tries). On networks that hiccup, raising the expel timeout reduces pointless expulsions at the cost of slower failure handling. Pick the value from your network, not from a blog post, ours included.
dba.checkInstanceConfiguration(), dba.configureInstance()), creates the group and adds members. MySQL Router, bootstrapped against the cluster, sends classic protocol read-write traffic to port 6446 and read-only traffic to 6447 by default (Router bootstrapping), and follows the primary after a failover. Use them unless you have a reason not to; hand-built groups are where most of the odd incidents we see come from.Monitoring what matters
SELECT member_host, member_state, member_role
FROM performance_schema.replication_group_members;
SELECT member_id,
count_transactions_in_queue, -- waiting for certification
count_transactions_remote_in_applier_queue, -- certified, waiting to apply
count_conflicts_detected
FROM performance_schema.replication_group_member_stats;
member_stateshould beONLINEeverywhere.RECOVERINGmeans the member is still catching up,UNREACHABLEmeans failure detection suspects it, andERRORmeans it stopped participating after an applier or recovery error (replication_group_members).- Applier queue (
count_transactions_remote_in_applier_queue) is the Group Replication version of replica lag. The causes and fixes overlap heavily with classic replication; see our guide to MySQL replication lag. - Conflicts (
count_conflicts_detected) should stay near zero in single-primary mode. A rising number points at multi-primary writes to the same rows (member stats).
On large databases
Group Replication behaves the same on 10 GB and 10 TB, but the margins disappear. These are the things that hurt at scale:
- The transaction size limit.
group_replication_transaction_size_limitdefaults to 150,000,000 bytes, about 143 MB. Larger transactions are rolled back. ADELETEof last year's rows or a bigLOAD DATAthat worked fine on asynchronous replication now fails. Batch them into small chunks. - Big messages get members expelled. The manual warns that if a transaction's message cannot be copied between members within the 5-second window, members can be suspected and expelled just because they are busy. Raising the limit without raising the expel timeout makes this worse.
- Flow control slows the primary down. When the certifier or applier queue on any member exceeds 25,000 transactions (the default thresholds), flow control throttles writers. One secondary on slower disks, or one replaying a long
ALTER TABLE, slows commits for the whole application. In our experience this is the most common "the database got slow after we moved to InnoDB Cluster" ticket. - Adding a member means copying everything. A joining member recovers from a donor's binary log, or with the clone plugin when the gap is large or the needed binlogs are already purged (distributed recovery). Without the clone plugin there is no fallback when binlogs are gone. On a multi-terabyte data set the clone is a full copy over the network, so plan bandwidth, donor I/O and the hours it takes, and do not start it during peak traffic.
- Distance costs commit time. The manual says Group Replication is designed for members that are very close to each other, and both latency and bandwidth affect stability. In our experience every commit pays at least one round trip to a majority, so a member in another region adds that latency to every write. Keep one group in one region (spread across zones), and use asynchronous replication between clusters for disaster recovery; the trade-offs are in our lessons from cloud zone outages.
- Gap locks and
LOCK TABLESare invisible to certification. Applications that rely onGET_LOCK()or table locks for coordination need a review, especially in multi-primary mode. - Practice failover with real data. Kill the primary under a realistic write load and measure how long the application sees errors and how long
BEFORE_ON_PRIMARY_FAILOVERholds new transactions. Numbers from an empty test cluster tell you nothing about a busy 5 TB one.
Key takeaways
- Group Replication agrees on commit order across a majority; secondaries still apply changes afterwards.
- Run an odd number of members, normally 3 or 5, in one region; the maximum is 9.
- Before migrating, fix tables without primary keys, non-InnoDB tables and GTID settings.
- The default consistency in 8.4 is
BEFORE_ON_PRIMARY_FAILOVER; raise it per session only where needed. - Set a finite
group_replication_unreachable_majority_timeout; the default 0 waits forever. - On large data, batch writes under the 143 MB limit, watch flow control queues, install the clone plugin and plan member provisioning.