MySQL 8.0.14 Group Replication Read/Write Consistency: Parameters, Levels, and Use Cases
MySQL 8.0.14 introduces a read/write consistency feature for Group Replication, explaining why MGR can still be inconsistent, detailing the group_replication_consistency parameter with its five levels, their advantages, disadvantages, and appropriate application scenarios, plus example session settings.
MySQL 8.0.14 adds a new feature called read/write consistency for Group Replication (MGR), addressing concerns that MGR may still produce inconsistent reads despite being a replication solution.
The inconsistency arises because MGR performs conflict‑check coordination before the relay log, but binlog replay can still be delayed, similar to semi‑synchronous replication.
To handle consistency, MySQL introduces the group_replication_consistency system variable, which can be set at the GLOBAL, SESSION, or LOCAL level. The variable supports five possible values:
EVENTUAL (default): Transactions do not wait for prior transactions to be replayed, nor do later transactions wait for them.
BEFORE : A transaction must wait for all preceding transactions to be replayed before it starts, ensuring it runs on the latest data.
AFTER : A transaction must finish replay before any subsequent transaction can start, guaranteeing that later transactions read the newest state.
BEFORE_AND_AFTER : The transaction waits for preceding transactions and also blocks subsequent transactions until it is replayed.
BEFORE_ON_PRIMARY_FAILOVER : During a primary failover, transactions connecting to the new primary are blocked until prior transactions are replayed, preserving consistency.
The feature has both advantages and drawbacks. Advantages include the ability to combine MGR with middleware (e.g., DBLE) for read/write splitting without worrying about stale reads, fully utilizing non‑primary nodes. The main drawback is a significant performance impact, especially in unstable network environments.
Choosing the appropriate consistency level depends on the workload:
AFTER is suitable for read‑heavy scenarios where stale reads are unacceptable, such as read‑only clusters that still need up‑to‑date data.
BEFORE fits write‑intensive workloads that occasionally need consistent reads.
BEFORE_AND_AFTER is ideal for clusters where reads must always see the latest writes and subsequent transactions must also see those writes.
Specific session settings can be applied with SQL statements, for example: SET @@SESSION.group_replication_consistency='AFTER'; or SET @@SESSION.group_replication_consistency='BEFORE'; For detailed configuration options and official documentation, refer to the MySQL reference pages:
Group Replication Options
Configuring Consistency Guarantees
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
