Parallel Replication

Last updated: 2023-08-31 16:55:27

Feature Overview

Prior to MySQL 5.6, the source node syncs binlogs and the replica node replays binlogs, both in the single-thread mode. MySQL 5.6 and later versions support the DATABASE/LOGICAL_CLOCK parallel replication scheme, but the granularity is too large to achieve expected parallel replication in many cases.
Tencent Cloud's TXSQL kernel team has optimized the parallel replication scheme. Table parallel replication is now supported, improving parallelism and reducing source-replica delay.

Supported Versions

Kernel version: MySQL 8.0 20201230 and later.
Kernel version: MySQL 5.7 20180530 and later.
Kernel version: MySQL 5.6 20170830 and later.

Scenarios

This feature is suitable for use cases where optimizing the parallelism of some loads can speed up the binlog replay at the replica node, thus reducing the source-replica delay.

Notes

Note: To enable parallel replication capability, set the parameter "slave_parallel_workers" to a non-zero value. In the high-stability parameter template of MySQL 5.6, 5.7, and 8.0, the default value for this parameter is 0; while in the high-performance parameter template, the default value for this parameter is 8.
To perform parallel replication at the table level in MySQL 5.6 and 5.7, set the "slave_parallel_type" to the newly added value "TABLE” when "slave_parallel_workers" is a non-zero value. MySQL 8.0 does not support the TABLE mode.
Additionally, the cdb_slave_thread_status table is added to the information_schema database to display the thread status of the replica node.
MySQL 5.6 Version Related Parameter Descriptions
MySQL 5.7 Version Parameter Descriptions
MySQL 8.0 Version Related Parameter Descriptions
Parameter
Effective Immediately
Local Disk Types
Default Value
Valid Values/
Value Range
Note
slave_parallel_type
YES
char*
SCHEMA
SCHEMA/TABLE
The level of parallel replication on the replica node:
SCHEMA: Replication events of different schemas can be executed in parallel.
TABLE: Replication events of different tables can be executed in parallel.

Parameter
Effective Immediately
Local Disk Types
Default Value
Valid Values/
Value Range
Note
slave_parallel_type
YES
char*
LOGICAL_CLOCK
DATABASE/TABLE/LOGICAL_CLOCK
The level of parallel replication on the replica node:
DATABASE: Replication events of different databases can be executed in parallel.
TABLE: Replication events of different tables can be executed in parallel.
LOGICAL_CLOCK: Replication events of the same logical clock on the host can be executed in parallel.

Parameter
Effective Immediately
Local Disk Types
Default Value
Valid Values/
Value Range
Note
slave_parallel_type
YES
char*
LOGICAL_CLOCK
DATABASE/LOGICAL_CLOCK
The level of parallel replication on the replica node:
DATABASE: Replication events of different databases can be executed in parallel.
LOGICAL_CLOCK: Replication events of the same logical clock on the host can be executed in parallel.