All pages
Powered by GitBook
1 of 31

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Replication

This section covers configuring and managing master-replica setups to ensure data redundancy and improve read scalability.

Replication Statements

Access the complete reference of SQL statements used to manage replication. This guide covers commands for controlling primaries, configuring replicas, and monitoring status.

Replication SQL statements can be found in the Reference section.

Replication Overview

Explore the core concepts of MariaDB standard replication. Learn about the primary-replica architecture, data redundancy strategies, and how to scale read operations effectively.

Replication is a feature allowing the contents of one or more servers (called primaries) to be mirrored on one or more servers (called replicas).

You can exert control over which data to replicate. All databases, one or more databases, or tables within a database can each be selectively replicated.

The main mechanism used in replication is the binary log. If binary logging is enabled, all updates to the database (data manipulation and data definition) are written into the binary log as binlog events. Replicas read the binary log from each primary in order to access the data to replicate. A relay log is created on the replica, using the same format as the binary log, and this is used to perform the replication. Old relay log files are removed when no longer needed.

A replica server keeps track of the position in the primary's binlog of the last event applied on the replica. This allows the replica server to re-connect and resume from where it left off after replication has been temporarily stopped. It also allows a replica to disconnect, be cloned and then have the new replica resume replication from the same primary.

Primaries and replicas do not need to be in constant communication with each other. It's quite possible to take servers offline or disconnect from the network, and when they come back, replication will continue where it left off.

Replication Uses

Replication is used in a number of common scenarios. Uses include:

  • Scalability. By having one or more replicas, reads can be spread over multiple servers, reducing the load on the primary. The most common scenario for a high-read, low-write environment is to have one primary, where all the writes occur, replicating to multiple replicas, which handle most of the reads.

  • Data analysis. Analyzing data may have too much of an impact on a primary server, and this can similarly be handled on a replica, while the primary continues unaffected by the extra load.

  • Backup assistance. can more easily be run if a server is not actively changing the data. A common scenario is to replicate the data to a replica, which is then disconnected from the primary with the data in a stable state. Backup is then performed from this server. See .

Common Replication Setups

Standard Replication

  • Provides infinite read scale out.

  • Provides high-availability by upgrading replica to primary.

Ring Replication

  • Provides read and write scaling.

  • Doesn’t handle conflicts.

  • If one primary fails, replication stops.

Ring Replication with slaves

  • Provides read and write scaling.

  • Doesn’t handle conflicts.

  • If one primary fails, replication stops.

Ring Replication with replication through slaves

  • Provides read and write scaling.

  • Doesn’t handle conflicts.

  • If one primary fails, replication stops.

Star Replication

  • Provides read and write scaling.

  • Doesn’t handle conflicts.

  • Have to use replication filters to avoid duplication of data.

  • , which is a multi-primary (multi-master) cluster for MariaDB, has a similar configuration and can handle conflicts.

Multi-Source Replication

  • Allows you to combine data from different sources.

  • Different domains executed independently in parallel on all replicas.

Cross-Version Replication Compatibility

The following table describes replication compatibility between different MariaDB Server versions. In general, the replica should be of the same or a later version. The constraint also applies to minor/patch releases:

  • ✅: This combination is supported.

  • ⛔: This combination is not supported.

Note: where it is not officially supported to replicate to a server with a lesser minor version, replication can still be safe for:

  • DMLs logged in ROW binlog_format, and

  • DMLS logged in STATEMENT format and DDLs where neither use features that do not yet exist on the replica

provided the configurations for each server allow for consistent behavior in the execution of the events (i.e. the execution of the event should not be reliant on newer configuration variables, character sets/collations, etc, that don't exist on the replica). Additionally note, if binlog_format=MIXED, it may be possible that the higher-versioned server (primary) may consider it safe to log a transaction using STATEMENT binlog format, while the older-versioned replica categorizes it as unsafe, which will result in an error while the replica tries to execute the transaction. See for more details on unsafe statements.

For replication compatibility details between MariaDB and MySQL, see .

See Also

  • (video)

This page is licensed: CC BY-SA / Gnu FDL

Distribution of data. Instead of being connected to a remote primary, it's possible to replicate the data locally and work from this data instead.

✅

⛔

⛔

⛔

⛔

⛔

✅

✅

⛔

⛔

⛔

⛔

✅

✅

✅

⛔

⛔

⛔

✅

✅

✅

✅

⛔

⛔

✅

✅

✅

✅

✅

⛔

✅

✅

✅

✅

✅

✅

Primary→

MariaDB 10.6

MariaDB 10.11

MariaDB 11.4

MariaDB 11.8

Replica ↓

Backups
Replication as a Backup Solution
Setting up standard replication
More about Multi-master ring replication
More about Multi-master ring replication
More about Multi-master ring replication
MariaDB Galera Cluster
More about Multi-Source replication
this page
Setting Up Replication
MariaDB Galera Cluster and M/S replication
standard_replication
ring_replication
star_replication
multi_source_replication

XtraDB option --innodb-release-locks-early

The --innodb-release-locks-early feature (MWL#163) was included in the 5.2 replication preview. However, it was omitted from due to the bug lp:798213.

This page is licensed: CC BY-SA / Gnu FDL

Row-based Replication With No Primary Key

Understand the performance implications and best practices for replicating tables without primary keys when using row-based logging, including how to avoid full table scans.

The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

MariaDB improves on row-based (see ) of tables which have no primary key but do have some other index. This is based in part on the original Percona patch "row_based_replication_without_primary_key.patch", with some additional fixes and enhancements.

When row-based replication is used with or , the slave needs to locate each replicated row based on the value in columns. If the table contains at least one index; an index lookup will be used (otherwise a table scan is needed for each row, which is extremely inefficient for all but the smallest table and generally to be avoided).

LOAD TABLE FROM MASTER (removed)

Syntax

Description

This feature has been removed from recent versions of MariaDB.

Since the current implementation of and LOAD TABLE FROM MASTER

Restricting Speed of Reading Binlog from Primary by a Replica

Configure throughput limits for replication traffic. Learn to throttle the binlog download speed to prevent replication from consuming all available network bandwidth.

When a replica starts after being stopped for some time, or a new replica starts that was created from a backup from some time back, a lot of old binlog events may need to be downloaded from the primary. If this happens from many replicas simultaneously, it can put a lot of load on the primary.

The read_binlog_speed_limit option can be used to reduce such load, by limiting the speed at which events are downloaded. The limit is given as maximum kilobytes per second to download on one replica connection.

With this option set, the replication I/O thread will limit the rate of download. Since the I/O thread is often much faster to download events than the SQL thread is at applying them, an appropriate value forread_binlog_speed_limit may reduce load spikes on the primary without much limit in the speed of the replica.

The option read_binlog_speed_limit is available starting from .

is very limited, these statements are deprecated in versions 4.1 of MySQL and above. We will introduce a more advanced technique (called "online backup") in a future version. That technique will have the additional advantage of working with more storage engines.

For MariaDB and MySQL 5.1 and earlier, the recommended alternative solution to using LOAD DATA FROM MASTER orLOAD TABLE FROM MASTER is using mysqldump or mysqlhotcopy. The latter requires Perl and two Perl modules (DBI and DBD:mysql) and works for MyISAM and ARCHIVE tables only. With mysqldump, you can create SQL dumps on the master and pipe (or copy) these to a mysql client on the slave. This has the advantage of working for all storage engines, but can be quite slow, since it works using SELECT.

Transfers a copy of the table from the master to the slave. This statement is implemented mainly debugging LOAD DATA FROM MASTER operations. To use LOAD TABLE, the account used for connecting to the master server must have the RELOAD and SUPER privileges on the master and theSELECT privilege for the master table to load. On the slave side, the user that issues LOAD TABLE FROM MASTER must have privileges for dropping and creating the table.

The conditions for LOAD DATA FROM MASTER apply here as well. For example, LOAD TABLE FROM MASTER works only for MyISAM tables. The timeout notes for LOAD DATA FROM MASTER apply as well.

This page is licensed: GPLv2, originally from fill_help_tables.sql

LOAD DATA FROM MASTER
LOAD TABLE tbl_name FROM MASTER

In MariaDB, the slave will try to choose a good index among any available:

  • The primary key is used, if there is one.

  • Else, the first unique index without NULL-able columns is used, if there is one.

  • Else, a choice is made among any normal indexes on the table (e.g. a FULLTEXT index is not considered).

The choice of which of several non-unique indexes to use is based on the cardinality of indexes; the one that is most selective (has the smallest average number of rows per distinct tuple of column values) is preferred. Note that for this choice to be effective, for most storage engines (like MyISAM, InnoDB) it is necessary to make sure ANALYZE TABLE has been run on the slave, otherwise statistics about index cardinality will not be available. In the absence of index cardinality, the first unique index will be chosen, if any, else the first non-unique index.

Prior to , the slave would always choose the first index without considering cardinality. The slave could even choose an unusable index (like FULLTEXT) if no other index was available (MySQL Bug #58997), causing row-based replication to break in this case; this was also fixed in .

See Also

This page is licensed: CC BY-SA / Gnu FDL

MDEV-18777
replication
binary log formats
UPDATE
DELETE
read_binlog_speed_limit
  • Description: Maximum speed(KB/s) to read binlog from primary.

  • Command line: --read-binlog-speed-limit[=#]

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 4294967295

  • Introduced:

This page is licensed: CC BY-SA / Gnu FDL

MariaDB 10.6
MariaDB 10.11
MariaDB 11.4
MariaDB 11.8

Replication and Foreign Keys

Understand how foreign key constraints interact with replication. Learn best practices for managing cascading deletes and updates across primary and replica servers.

The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

Replication is based upon the . However, cascading deletes or updates based on foreign key relations are an internal mechanism, and are not written to the binary log.

Because of this, an identical statement run on the master and the slave may result in different outcomes if the foreign key relations are not identical on both master and slave This could be the case if the storage engine on one supports cascading deletes (e.g. InnoDB) and the storage engine on the other does not (e.g. MyISAM), or the one has specified a foreign key relation, and the other hasn't.

Binlog Event Checksums

Configure checksums to detect data corruption in binary logs. Learn how to enable verification to ensure the integrity of replication events during transmission and storage.

The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

MariaDB includes a feature to include a checksum in events.

Checksums are enabled with the , which is set to CRC32 by default.

The variable can be changed dynamically without restarting the server. Setting the variable in any way (even to the existing value) forces a rotation of the

LOAD DATA FROM MASTER (removed)

Syntax

Description

This feature has been removed from recent versions of MariaDB.

Since the current implementation of LOAD DATA FROM MASTER

and
is very limited, these statements are deprecated in versions 4.1 of MySQL and above. We will introduce a more advanced technique (called "online backup") in a future version. That technique will have the additional advantage of working with more storage engines.

For MySQL 5.1 and earlier, the recommended alternative solution to using LOAD DATA FROM MASTER orLOAD TABLE FROM MASTER is using mysqldump or mysqlhotcopy. The latter requires Perl and two Perl modules (DBI and DBD:mysql) and works for MyISAM and ARCHIVE tables only. With mysqldump, you can create SQL dumps on the master and pipe (or copy) these to a mysql client on the slave. This has the advantage of working for all storage engines, but can be quite slow, since it works using SELECT.

This statement takes a snapshot of the master and copies it to the slave. It updates the values of MASTER_LOG_FILE andMASTER_LOG_POS so that the slave starts replicating from the correct position. Any table and database exclusion rules specified with the--replicate-*-do-* and--replicate-*-ignore-* options are honored.--replicate-rewrite-db is not taken into account because a user could use this option to set up a non-unique mapping such as--replicate-rewrite-db="db1->db3" and--replicate-rewrite-db="db2->db3", which would confuse the slave when loading tables from the master.

Use of this statement is subject to the following conditions:

  • It works only for MyISAM tables. Attempting to load a non-MyISAM table results in the following error:ERROR 1189 (08S01): Net error reading from master

  • It acquires a global read lock on the master while taking the snapshot, which prevents updates on the master during the load operation.

If you are loading large tables, you might have to increase the values ofnet_read_timeout and net_write_timeout on both the master and slave servers. See Server System Variables.

Note that LOAD DATA FROM MASTER does not copy any tables from the mysql database. This makes it easy to have different users and privileges on the master and the slave.

To use LOAD DATA FROM MASTER, the replication account that is used to connect to the master must have the RELOAD and SUPER privileges on the master and theSELECT privilege for all master tables you want to load. All master tables for which the user does not have theSELECT privilege are ignored byLOAD DATA FROM MASTER. This is because the master hides them from the user: LOAD DATA FROM MASTER callsSHOW DATABASES to know the master databases to load, but SHOW DATABASES returns only databases for which the user has some privilege. On the slave side, the user that issues LOAD DATA FROM MASTER must have privileges for dropping and creating the databases and tables that are copied.

This page is licensed: GPLv2, originally from fill_help_tables.sql

LOAD TABLE FROM MASTER
Take the following example:

The slave, however, has been set up without InnoDB support, and defaults to MyISAM, so the foreign key restrictions are not in place.

At this point, the slave and the master are in sync:

However, after:

there are different outcomes on the slave and the master.

On the master, the cascading deletes have taken effect:

On the slave, the cascading deletes did not take effect:

This page is licensed: CC BY-SA / Gnu FDL

MDEV-18777
binary log
CREATE TABLE employees (
    x INT PRIMARY KEY,
    name VARCHAR(10)
) ENGINE = InnoDB;

CREATE TABLE children (
    y INT PRIMARY KEY,
    f INT,
    name VARCHAR(10),
    FOREIGN KEY fk (f) REFERENCES employees (x)
        ON DELETE CASCADE
) ENGINE = InnoDB;
INSERT INTO employees VALUES (1, 'Yaser'), (2, 'Prune');

INSERT INTO children VALUES (1, 1, 'Haruna'), (2, 1, 'Hera'), (3, 2, 'Eva');
LOAD DATA FROM MASTER
SELECT * FROM employees;
+---+-------+
| x | name  |
+---+-------+
| 1 | Yaser |
| 2 | Prune |
+---+-------+
2 rows in set (0.00 sec)

SELECT * FROM children;
+---+------+--------+
| y | f    | name   |
+---+------+--------+
| 1 |    1 | Haruna |
| 2 |    1 | Hera   |
| 3 |    2 | Eva    |
+---+------+--------+
DELETE FROM employees WHERE x=1;
SELECT * FROM children;
+---+------+------+
| y | f    | name |
+---+------+------+
| 3 |    2 | Eva  |
+---+------+------+
SELECT * FROM children;
+---+------+--------+
| y | f    | name   |
+---+------+--------+
| 1 |    1 | Haruna |
| 2 |    1 | Hera   |
| 3 |    2 | Eva    |
+---+------+--------+
(the intention is to avoid having a single binlog where some events are checksummed and others are not).

When checksums are enabled, replicas will check events received over the network for checksum errors, and will stop with an error if a corrupt event is detected.

In addition, the server can be configured to verify checksums in two other places.

One is when reading events from the binlog on the primary, for example when sending events to a replica or for something like SHOW BINLOG EVENTS. This is controlled by the master_verify_checksum option, and is thus used to detect file system corruption of the binlog files.

The other is when the replica SQL thread reads events from the relay log. This is controlled by the slave_sql_verify_checksum option, and is used to detect file system corruption of replica relay log files.

MariaDB starting with 11.4

From MariaDB 11.4, binlog checksums are computed when writing events into the statement or transaction caches, where before this was done when the caches were copied to the real binlog file. This moves the checksum computation outside of holding LOCK_log, improving scalability. See MDEV-31273.

master_verify_checksum

  • Description: Verify binlog checksums when reading events from the binlog on the primary.

  • Command line: --master_verify_checksum=[0|1]

  • Scope: Global

  • Access Type: Can be changed dynamically

  • Data Type: bool

  • Default Value: OFF (0)

slave_sql_verify_checksum

  • Description: Verify binlog checksums when the replica SQL thread reads events from the relay log.

  • Command line: --slave_sql_verify_checksum=[0|1]

  • Scope: Global

  • Access Type: Can be changed dynamically

  • Data Type: bool

  • Default Value: ON (1)

The mariadb-binlog client program by default does not verify checksums when reading a binlog file, however it can be instructed to do so with the option verify-binlog-checksum:

  • Variable Name: verify-binlog-checksum

  • Data Type: bool

  • Default Value: OFF

See Also

  • Binlog Event Checksum Interoperability

This page is licensed: CC BY-SA / Gnu FDL

MDEV-18777
binary log
binlog_checksum option
binary log

Changing a Replica to Become the Primary

Follow the procedure to promote a replica to a primary role. This guide details the steps for planned failovers or topology reorganization with minimal downtime.

The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

This article describes how to change a replica to become a primary and optionally to set the old primary as a replica for the new primary.

A typical scenario of when this is useful is if you have set up a new version of MariaDB as a replica, for example for testing, and want to upgrade your primary to the new version.

In MariaDB replication, a replica should be of a version same or newer than the primary. Because of this, one should first upgrades all replicas to the latest version before changing a replica to be a primary. In some cases one can have a replica to be of an older version than the primary, as long as one doesn't execute on the primary any SQL commands that the replica doesn't understand. This is however not guaranteed between all major MariaDB versions.

Note that in the examples below, [connection_name] is used as the . If you are not using named connections you can ignore this.

Stopping the Original Master.

First one needs to take down the original primary in such a way that the replica has all information on the primary.

If you are using you can just stop the server with the command as the replicas should be automatically up to date.

If you are using , then you to handle the whole process of taking down the primary and replacing it with one of the replicas.

If neither of the above is true, you have to do this step manually:

Manually Take Down the Primary

First we have to set the primary to read only to ensure that there are no new updates on the primary:

Note that you should not disconnect this session as otherwise the read lock will disappear and you have to start from the beginning.

Then you should check the current position of the primary:

And wait until you have the same position on the replica: (The following should be expected on the replica)

The most important information to watch are Master_Log_File andExec_Master_Log_Pos as when this matches the primary, it signals that all transactions have been committed on the replica.

Note that Gtid_IO_Pos on replica can contain many different positions separated with ',' if the replica has been connected to many different primaries. What is important is that all the sequences that are on the primary is also on the replica.

When replica is up to date, you can then take the PRIMARY down. This should be on the same connection where you executed .

Preparing the Replica to be a Primary

Stop all old connections to the old primary(s) and reset read only mode, if you had it enabled. You also want to save the values of and gtid_binlog_pos, as you may need these to setup new replicas.

Reconnect Other Replicas to the New Primary

On the other replicas you have point them to the new primary (the replica you promoted to a primary).

The XXX values for MASTER_LOG_FILE and MASTER_LOG_POS should be the values you got from the SHOW MASTER STATUS command you did when you finished setting up the replica.

Changing the Old Primary to be a Replica

Now you can upgrade the old primary to a newer version of MariaDB and then follow the same procedure to connect it as a replica.

When starting the original primary, it's good to start the mysqld executable with the --with-skip-slave-start and --read-only options to ensure that no old replica configurations could cause any conflicts.

For the same reason it's also good to execute the following commands on the old primary (same as for other replicas, but with some extra security). The read_only option below is there to ensure that old applications doesn't by accident try to update the old primary by mistake. It only affects normal connections to the replica, not changes from the new primary.

Moving Applications to Use New Primary

You should now point your applications to use the new primary. If you are using the , then you don't have to do this step as MaxScale will take care of sending write request to the new primary.

See Also

  • command

This page is licensed: CC BY-SA / Gnu FDL

Delayed Replication

Learn to configure a time lag for your replica. Delayed replication helps recover from human errors on the primary, such as accidental drop commands, by preserving older states.

The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

Delayed replication allows specifying that a replica should lag behind the primary by (at least) a specified amount of time (specified in seconds). Before executing an event, the replica will first wait, if necessary, until the given time has passed since the event was created on the primary. The result is that the replica will reflect the state of the primary some time back in the past.

The default is zero, or no delay, and the maximum value is 2147483647, or about 68 years.

Delayed replication is enabled using the MASTER_DELAY option to :

A zero delay disables delayed replication. The replica must be stopped when changing the delay value.

New Variables to Measure Replication Lag

MariaDB 10.6 ES and 11.6 introduced new variables to measure replication lag. The variables are recommended to monitor the time difference between the master and slave.

  • Master_last_event_time: The timestamp of the last event read from the master by the IO thread.

Fields in are associated with delayed replication

  1. SQL_Delay: This is the value specified by MASTER_DELAY in CHANGE MASTER (or 0 if none).

  2. SQL_Remaining_Delay: When the replica is delaying the execution of an event due to MASTER_DELAY, this is the number of seconds of delay remaining before the event will be applied. Otherwise, the value is NULL.

  3. Seconds_Behind_Master:

  • If replication is not active, the value is NULL.

  • If all events has been executed and slave is now idle (waiting for new events), the value is 0.

  • If using parallel replication:

    • When starting to execute a new delayed event on an idle slave the value is clock_time_on_slave - clock_when_started_execution_of_the_event_on_master - clock_difference_between_master_and_slave

  1. Slave_SQL_Running_State: This shows the state of the SQL driver threads, same as in . When the replica is delaying the execution of an event due to MASTER_DELAY, this fields displays: "Waiting until MASTER_DELAY seconds after master executed event".

When using older versions prior to , a 3rd party tool called can be used. It is part of the Percona Toolkit. Note that pt-slave-delay does not support MariaDB multi-channel replication syntax.

clock_difference_between_master_and_slave

When setting up a master and slaves it is important that the internal clock has the same configuration. In almost all unix systems the internal clock is in UTC by default. On Windows system it may be in local time. This should be changed to be in UTC if one uses MariaDB with replication!

In addition to being in UTC, one should ensure that the clocks are synchronized. If not properly synchronized, there is a gap between the values of the clocks between different machines. MariaDB replication takes this into account by comparing the master and slave clocks when the slave connects to the master. The difference is clock_difference_between_master_and_slave.

This page is licensed: CC BY-SA / Gnu FDL

Read-Only Replicas

Learn how to configure replicas as read-only instances. This ensures data integrity by preventing accidental writes on the replica while allowing it to process replication events.

A common replication setup is to have the replicas read-only to ensure that no one accidentally updates them. If the replica has binary logging enabled and gtid_strict_mode is used, then any update that causes changes to the binary log will stop replication.

When the variable read_only is set to 1, no updates are permitted except from users with the SUPER privilege (<= ) or READ ONLY ADMIN privilege (>= ) or replica servers updating from a primary. Inserting rows to log tables, updates to temporary tables and OPTIMIZE TABLE or ANALYZE TABLE statements on temporary tables are excluded from this limitation.

If read_only is set to 1, then the SET PASSWORD statement is limited only to users with the SUPER privilege (<= ) or READ ONLY ADMIN privilege (>= ).

Attempting to set the read_only variable to 1 will fail if the current session has table locks or transactions pending.

The statement will wait for other sessions that hold table locks. While the attempt to set read_only is waiting, other requests for table locks or transactions will also wait until read_only has been set.

Older MariaDB Versions

If you are using an older MariaDB version with read-only replicas and binary logging enabled on the replica, and you need to do some changes but don't want to have them logged to the binary log, the easiest way to avoid the logging is to while running as root during maintenance:

The above changes the test table on the replica to rocksdb without registering the change in the binary log.

This page is licensed: CC BY-SA / Gnu FDL

name of the connection
Semisynchronous Replication
SHUTDOWN
can use MaxScale
FLUSH TABLES WITH READ LOCK
SHOW MASTER STATUS
CHANGE MASTER TO
MaxScale Blog about using Switchover to swap a primary and replica
Percona blog about how to upgrade replica to primary
MariaDB MaxScale proxy
MariaDB MaxScale proxy
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
+--------------------+----------+--------------+------------------+
| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000003 |      343 |              |                  |
+--------------------+----------+--------------+------------------+
SELECT @@global.gtid_binlog_pos;
+--------------------------+
| @@global.gtid_binlog_pos |
+--------------------------+
| 0-1-2                    |
+--------------------------+
SHOW SLAVE [connection_name] STATUS;
+-------------------+-------------------+
Master_Log_File     | narttu-bin.000003 +
Read_Master_Log_Pos | 343               +
Exec_Master_Log_Pos | 343               +
...
Gtid_IO_Pos          0-1-2              +
+-------------------+-------------------+
SHUTDOWN;
STOP ALL SLAVES;
RESET SLAVE ALL;
SHOW MASTER STATUS;
SELECT @@global.gtid_binlog_pos;
SET @@global.read_only=0;
STOP SLAVE [connection_name];
CHANGE MASTER [connection_name] TO 
 MASTER_HOST="new_master_name",
 MASTER_PORT=3306, 
 MASTER_USER='root', 
 MASTER_USE_GTID=current_pos,
 MASTER_LOG_FILE="XXX", 
 MASTER_LOG_POS=XXX;
START SLAVE;
SET @@global.read_only=1;
STOP ALL SLAVES;
RESET MASTER;
RESET SLAVE ALL;
CHANGE MASTER [connection_name] TO 
 MASTER_HOST="new_master_name",
 MASTER_PORT=3306, 
 MASTER_USER='root', 
 MASTER_USE_GTID=current_pos,
 MASTER_LOG_FILE="XXX", 
 MASTER_LOG_POS=XXX;
START SLAVE;

Slave_last_event_time: The timestamp of the last event committed on the slave (from the master's perspective).

  • Master_Slave_time_diff: The difference in seconds between Master_last_event_time and Slave_last_event_time.

  • When event is committed the value is updated to: clock_time_on_slave - clock_when_ending_execution_of_the_event_on_master - clock_difference_between_master_and_slave

  • As Seconds_Behind_Master value depends on the timestamp of the last executed event, its value can be much bigger than SQL_Delay. For example if SQL_delay is 10 hours and the master sends a new event after not having executed anything for 20 hours, Seconds_behind_master will be 30 hours. When event starts to execute, Seconds_behind_master will still be growing until it commits. Then it will be changed to about 10 hours (more precisely to 10 hours + execution_time_on_slave - execution_time_on_master which corresponds to the above bullet). Since that the value will be growing until next event is executed and Seconds_behind_master is rebased on its completion time again. To expand more on this check a practical example in the comments.

  • If not using parallel replication the value is updated when starting to execute an event. The value is set to: clock_time_on_slave - clock_when_started_execution_of_the_event_on_master - clock_difference_between_master_and_slave. Note that in this case the clock is at start of event, not at end of event like in parallel replication.

  • CHANGE MASTER
    SHOW SLAVE STATUS
    SHOW PROCESSLIST
    pt-slave-delay
    disable binary logging

    Binlog Event Checksum Interoperability

    Learn about checksum compatibility between different MariaDB versions. Ensure older replicas can correctly verify binary log events generated by newer primaries.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    The introduction of checksums on binlog events changes the format that events are stored in binary log files and sent over the network to replicas. This raises the question on what happens when replicating between different versions of the server, where one server is a newer version that has the binlog checksum feature implemented, while the other server is an older version that does not know about binlog checksums.

    When checksums are disabled on the primary (or the primary has the old version with no checksums implemented), there is no problem. In this case the binlog format is backwards compatible, and replication works fine.

    When the primary is a newer version with checksums enabled in the binlog, but the replica is an old version that does not understand checksums, replication will fail. The primary will disconnect the replica with an error, and also log a warning in its own error log. This prevents sending events to the replica that it will be unable to interpret correctly, but means that binlog checksums can not be used with older replicas. (With the recommended upgrade path, where replicas are upgraded before primaries, this is not a problem of course).

    Replicating from a new MySQL primary with checksums enabled to a new MariaDB which also understands checksums works, and the MariaDB replica will verify checksums on replicated events.

    There is however a problem when a newer MySQL replica replicates against a newer MariaDB primary with checksums enabled. The replica server looks at the primary server version to know whether events include checksums or not, and MySQL has not yet been updated to learn that MariaDB does this already from version 5.3.0 (as of the time of writing, MySQL 5.6.2). Thus, if MariaDB at least version 5.3.0 but less that 5.6.1 is used as a primary with binlog checksums enabled, a MySQL replica will interpret the received events incorrectly as it does not realise the last part of the events is the checksum. So replication will fail with an error about corrupt events or even silent corruption of replicated data in unlucky cases. This requires changes to the MySQL server to fix.

    Here is a summary table of the status of replication between different combination of primary and replica servers and checksum enabled/disabled:

    • OLD: MySQL <5.6.1 or MariaDB < 5.3.0 with no checksum capabilities

    • NEW-MARIA: MariaDB >= 5.3.0 with checksum capabilities

    • NEW-MYSQL: MySQL >= 5.6.1 with checksum capabilities

    Primary mariadb-lbinlog
    Replica / enabled?
    Checksums
    Status

    Checksums and mariadb-binlog

    When using the client program, there are similar issues.

    A version of mariadb-binlog which understands checksums can read binlog files from either old or new servers, with or without checksums enabled.

    An old version of mariadb-binlog can read binlog files produced by a new server version if checksums were disabled when the log was produced. Old versions of mariadb-binlog reading a new binlog file containing checksums will be confused, and output will be garbled, with the added checksums being interpreted as extra garbage at the end of query strings and similar entries. No error will be reported in this case, just wrong output.

    A version of mysqlbinlog (the MySQL equivalent to mariadb-binlog and the old MariaDB name for the binary) from MySQL >= 5.6.1 will have similar problems as a replica until this is fixed in MySQL. When reading a binlog file with checksums produced by MariaDB >= 5.3.0 but < 5.6.1, it will not realise that checksums are included, and will produce garbled output just like an old version ofmysqlbinlog. The MariaDB version of mariadb-binlog can read binlog files produced by either MySQL or MariaDB just fine.

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    Selectively Skipping Replication of Binlog Events

    Learn techniques to bypass specific replication events. This guide explains how to ignore individual transactions or errors to restore replication flow after a stoppage.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    Normally, all changes that are logged as events in the binary log are also replicated to all replicas (though still subject to filtering by replicate-do-db, replicate-ignore-db, and similar options). However, sometimes it may be desirable to have certain events be logged into the binlog, but not be replicated to all or a subset of replicas, where the distinction between events that should be replicated or not is under the control of the application making the changes.

    This could be useful if an application does some replication external to the server outside of the built-in replication, or if it has some data that should not be replicated for whatever reason.

    This is possible with the following .

    Primary Session Variable: skip_replication

    When the variable is set to true, changes are logged into the with the flag @@skip_replication set. Such events will not be replicated by replicas that run with--replicate-events-marked-for-skip set different from its default of REPLICATE.

    Variable Name
    skip_replication

    The skip_replication option only has effect if is enabled and is true.

    Attempting to change @@skip_replication in the middle of a transaction will fail; this is to avoid getting half of a transaction replicated while the other half is not replicated. Be sure to end any current transaction withCOMMIT/ROLLBACK before changing the variable.

    Replica Option: --replicate-events-marked-for-skip

    The option tells the replica whether to replicate events that are marked with the @@skip_replication flag. Default is REPLICATE, to ensure that all changes are replicated to the replica. If set to FILTER_ON_SLAVE, events so marked will be skipped on the replica and not replicated. If set toFILTER_ON_MASTER, the filtering will be done on the primary, saving on network bandwidth as the events will not be received by the replica at all.

    Variable Name
    replicate_events_marked_for_skip

    Note: replicate_events_marked_for_skip is a dynamic variable (it can be changed without restarting the server), however the replica threads must be stopped when it is changed, otherwise an error will be thrown.

    When events are filtered due to @@skip_replication, the filtering happens on the primary side; in other words, the event is never sent to the replica. If many events are filtered like this, a replica can sit a long time without receiving any events from the primary. This is not a problem in itself, but must be kept in mind when inquiring on the replica about events that are filtered. For example START SLAVE UNTIL <some position> will stop when the first event that is not filtered is encountered at the given position or beyond. If the event at the given position is filtered, then the replica thread will only stop when the next non-filtered event is encountered. In effect, if an event is filtered, to the replica it appears that it was never written to the binlog on the primary.

    Note that when events are filtered for a replica, the data in the database will be different on the replica and on the primary. It is the responsibility of the application to replicate the data outside of the built-in replication or otherwise ensure consistency of operation. If this is not done, it is possible for replication to encounter, for example, contraint violations or other problems which will cause replication to stop and require manual intervention to fix.

    The session variable @@skip_replication can be changed without requiring special privileges. This makes it possible for normal applications to control it without requiring SUPER privileges. But it must be kept in mind when using replicas with --replicate-events-marked-for-skip set different from REPLICATE, as it allows any connection to do changes that are not replicated.

    skip_replication and sql_log_bin

    and @@skip_replication are somewhat related, as they can both be used to prevent a change on the primary from being replicated to the replica. The difference is that with @@skip_replication, changes are still written into the binlog, and replication of the events is only skipped on replicas that explicitly are configured to do so, with--replicate-events-marked-for-skip different fromREPLICATE. With @@sql_log_bin, events are not logged into the binlog, and so are not replicated by any replica.

    skip_replication and the Binlog

    When events in the binlog are marked with the @@skip_replication flag, the flag will be preserved if the events are dumped by the program and re-applied against a server with the program. Similarly, the statement will preserve the flag from the event being replayed. And a replica which runs with--log-slave-updates and does not filter events (--replicate-events-marked-for-skip=REPLICATE) will also preserve the flag in the events logged into the binlog on the replica.

    See Also

    • - How to skip a number of events on the replica

    This page is licensed: CC BY-SA / Gnu FDL

    Replication When the Primary and Replica Have Different Table Definitions

    Understand the rules and limitations when replicating between tables with differing structures. Learn how attribute promotion and column handling work in row-based replication.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

    While replication is usually meant to take place between primaries and replicas with the same table definitions and this is recommended, in certain cases replication can still take place even if the definitions are identical.

    Tables on the replica and the primary do not need to have the same definition in order for to take place. There can be differing numbers of columns, or differing data definitions and, in certain cases, replication can still proceed.

    MariaDB 5.2 Replication Feature Preview

    Note: This page is obsolete. The information is old, outdated, or otherwise currently incorrect. We are keeping the page for historical reasons only. Do not rely on the information in this article.

    This page describes a "feature preview release" which previewed some replication-related features which are included in . If you would like to try out the features mentioned here, it is recommended that you use () instead of the actual release described below. Likewise, the code is available in the .

    About this release

    There has been quite a lot of interest in these features, and providing this feature preview release allows the developers to get more and earlier feedback, as well as allowing more users an early opportunity to evaluate the new features.

    CHANGE MASTER TO master_delay=3600;
    SET sql_log_bin=0;
    ALTER TABLE test ENGINE=rocksdb;

    Scope

    Session only

    Access Type

    Dynamic

    Data Type

    bool

    Default Value

    OFF

    Scope

    Global

    Access Type

    Dynamic

    Data Type

    enum: REPLICATE | FILTER_ON_SLAVE | FILTER_ON_MASTER

    Default Value

    REPLICATE

    system variables
    skip_replication
    binary log
    binary logging
    sql_log_bin
    replicate_events_marked_for_skip
    UNIQUE
    @@sql_log_bin
    mariadb-binlog
    mariadb client
    BINLOG
    Using SQL_SLAVE_SKIP_COUNTER

    NEW-MARIA

    OLD

    No

    Ok

    NEW-MARIA

    OLD

    Yes

    Primary will refuse with error

    NEW-MARIA

    NEW-MARIA

    Yes/No

    Ok

    NEW-MARIA

    NEW-MYSQL

    No

    Ok

    NEW-MARIA

    NEW-MYSQL

    Yes

    Fail. Requires changes in MySQL, otherwise it will not realise MariaDB < 5.6.1 does checksums and will be confused.

    NEW-MYSQL

    OLD

    No

    Ok

    NEW-MYSQL

    OLD

    Yes

    Primary will refuse with error

    NEW-MYSQL

    NEW-MARIA

    Yes/No

    Ok

    NEW-MYSQL

    NEW-MYSQL

    Yes/No

    Ok

    OLD

    OLD

    -

    Ok

    OLD

    NEW-MARIA

    -

    Ok

    OLD

    MYSQL

    -

    mariadb-binlog
    Binlog Event Checksums

    Ok

    Different Column Definitions - Attribute Promotion and Demotion

    It is possible in some cases to replicate to a replica that has a column of a different type on the replica and the primary. This process is called attribute promotion (to a larger type) or attribute demotion (to a smaller type).

    The conditions differ depending on whether statement-based or row-based replication is used.

    Statement-Based Replication

    When using statement-based replication, generally, if a statement can run successfully on the replica, it will be replicated. If a column definition is the same or a larger type on the replica than on the primary, it can replicate successfully. For example, a column defined as VARCHAR(10) will successfully be replicated on a replica with a definition of VARCHAR(12).

    Replicating to a replica where the column is defined as smaller than on the primary can also work. For example, given the following table definitions:

    Master:

    Slave

    the statement

    would successfully replicate because the value inserted into the v field can successfully be inserted on both the primary and the smaller replica equivalent.

    However, the following statement would fail:

    In this case, the value fits in the primary definition, but is too long for the replica field, and so replication will fail.

    Row-Based Replication

    When using row-based replication, the value of the slave_type_conversions variable is important. The default value of this variable is empty, in which case MariaDB will not perform attribute promotion or demotion. If the column definitions do not match, replication will stop. If set to ALL_NON_LOSSY, safe replication is permitted. If set to ALL_LOSSY as well, replication will be permitted even if data loss takes place.

    For example:

    Master:

    Slave:

    The following query will fail:

    By changing the value of the slave_type_conversions, replication can proceed:

    Supported Conversions

    • Between TINYINT, SMALLINT, MEDIUMINT, INT and BIGINT. If lossy conversion is supported, the value from the primary will be converted to the maximum or minimum permitted on the replica, which non-lossy conversions require the replica column to be large enough. For example, SMALLINT UNSIGNED can be converted to MEDIUMINT, but not SMALLINT SIGNED.

    Different Number or Order of Columns

    Replication can also take place when the primary and replica have a different number of columns if the following criteria are met:

    • columns must be in the same order on the primary and replica

    • common columns must be defined with the same data type

    • extra columns must be defined after the common columns

    Row-Based

    The following example replicates incorrectly (replication proceeds, but the data is corrupted), as the columns are not in the same order.

    Master:

    Slave:

    Master:

    Slave:

    Statement-Based

    Using statement-based replication, the same example may work, even though the columns are not in the same order.

    Master:

    Slave:

    Master:

    Slave:

    This page is licensed: CC BY-SA / Gnu FDL

    MDEV-18777
    replication
    DESC r;
    +-------+-------------+------+-----+---------+-------+
    | Field | Type        | Null | Key | Default | Extra |
    +-------+-------------+------+-----+---------+-------+
    | id    | tinyint(4)  | YES  |     | NULL    |       |
    | v     | varchar(10) | YES  |     | NULL    |       |
    +-------+-------------+------+-----+---------+-------+
    DESC r;
    +-------+-------------+------+-----+---------+-------+
    | Field | Type        | Null | Key | Default | Extra |
    +-------+-------------+------+-----+---------+-------+
    | id    | tinyint(4)  | YES  |     | NULL    |       |
    | v     | varchar(8) | YES   |     | NULL    |       |
    +-------+-------------+------+-----+---------+-------+
    INSERT INTO r VALUES (6,'hi');
    INSERT INTO r VALUES (7,'abcdefghi')
    SHOW SLAVE STATUS\G
    *************************** 1. row ***************************
    ...
    Slave_IO_Running: Yes
    Slave_SQL_Running: No
    ...
    Last_Errno: 1406
    Last_Error: Error 'Data too long for column 'v' at row 1' on query. 
       Default database: 'test'. Query: 'INSERT INTO r VALUES (7,'abcdefghi')'
    ...
    DESC r;
    +-------+-------------+------+-----+---------+-------+
    | Field | Type        | Null | Key | Default | Extra |
    +-------+-------------+------+-----+---------+-------+
    | id    | smallint(6) | YES  |     | NULL    |       |
    | v     | varchar(10) | YES  |     | NULL    |       |
    +-------+-------------+------+-----+---------+-------+
    SHOW VARIABLES LIKE 'slave_ty%';
    +------------------------+-------+
    | Variable_name          | Value |
    +------------------------+-------+
    | slave_type_conversions |       |
    +------------------------+-------+
    
     DESC r;
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | tinyint(4) | YES  |     | NULL    |       |
    | v     | varchar(1) | YES  |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    INSERT INTO r VALUES (3,'c');
    SHOW SLAVE STATUS\G;
    ...
    Slave_IO_Running: Yes
    Slave_SQL_Running: No
    ...
    Last_Errno: 1677
    Last_Error: Column 0 of table 'test.r' cannot be converted from 
      type 'smallint' to type 'tinyint(4)'
    ...
    SET GLOBAL slave_type_conversions='ALL_NON_LOSSY,ALL_LOSSY';
    
    START SLAVE;
    SHOW SLAVE STATUS\G;
    *************************** 1. row ***************************
    ...
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
    ...
    CREATE OR REPLACE TABLE r (i1 INT, i2 INT);
    ALTER TABLE r ADD i3 INT AFTER i1;
    INSERT INTO r (i1,i2) VALUES (1,1);
    
    SELECT * FROM r;
    +------+------+
    | i1   | i2   |
    +------+------+
    |    1 |    1 |
    +------+------+
    SELECT * FROM r;
    +------+------+------+
    | i1   | i3   | i2   |
    +------+------+------+
    |    1 |    1 | NULL |
    +------+------+------+
    CREATE OR REPLACE TABLE r (i1 INT, i2 INT);
    ALTER TABLE r ADD i3 INT AFTER i1;
    INSERT INTO r (i1,i2) VALUES (1,1);
    
    SELECT * FROM r;
    +------+------+
    | i1   | i2   |
    +------+------+
    |    1 |    1 |
    +------+------+
    SELECT * FROM r;
    +------+------+------+
    | i1   | i3   | i2   |
    +------+------+------+
    |    1 | NULL |    1 |
    +------+------+------+
    This feature preview release is based on , adding a number of fairly isolated features that are considered complete and fairly well-tested. It is however not a stable or GA release, nor is it planned to be so.

    The stable release including these features will be . That being said, we greatly welcome any feedback / bug reports, and will strive to fix any issues found and we will update the feature preview until stable is ready.

    Download/Installation

    These packages are generated the same way as "official" MariaDB releases. Please see the main download pages for more detailed instructions on installation etc.

    The instructions below use the mirror ftp.osuosl.org, but any of the MariaDB mirrors can be used by replacing the appropriate part of the URLs. See the main download page for what mirrors are available.

    Debian/Ubuntu

    For Debian and Ubuntu, it is highly recommended to install from the repositories, using apt-get, aptitude, or another favorite package managers.

    First import the public key with which the repositories are signed, so that apt can verify the integrity of the packages it downloads. For example, like this:

    Now add the appropriate repository. An easy way is to create a file calledmariadb-5.2-rpl.list in /etc/apt/sources.list.d/ with contents like this for Debian:

    Or this for Ubuntu:

    Replace "squeeze" or "maverick" in the examples above with the appropriate distribution name. Supported are "lenny" and "squeeze" for Debian, and "hardy", "jaunty", "karmic", "lucid", and "maverick" for Ubuntu.

    Now run

    The packages can now be installed with your package manager of choice, for example:

    (To manually download and install packages, browse the directories below- the .debs are indebian/pool/ and ubuntu/pool/, respectively.)

    Generic Linux binary tarball

    Generic linux binary tarballs can be downloaded here:

    • i386 (32-bit):

    • amd64 (64-bit):

    Centos 5 RPMs

    • i386 (32-bit):

    • amd64 (64-bit):

    Windows (32-bit)

    Source tarball

    Launchpad bzr branch:

    • lp:~maria-captains/maria/mariadb-5.2-rpl

    New Features in the replication feature preview

    Here is a summary of the new features included in this preview release. The headings link to more detailed information.

    Group commit for the binary log

    This preview release implements group commit which works when using XtraDB with the binary log enabled. (In previous MariaDB releases, and all MySQL releases at the time of writing, group commit works in InnoDB/XtraDB when the binary log is disabled but stops working when the binary log is enabled).

    Enhancements for START TRANSACTION WITH CONSISTENT SNAPSHOT

    START TRANSACTION WITH CONSISTENT SNAPSHOT now also works with the binary log. This means it is possible to obtain the binlog position corresponding to a transactional snapshot of the database without blocking any other queries. This is used by mysqldump --single-transaction --master-data to do a fully non-blocking backup which can be used to provision a new slave.

    START TRANSACTION WITH CONSISTENT SNAPSHOT now also works consistently between transactions involving more than one storage engine (currently XTraDB and PBXT support this).

    Annotation of row-based replication events with the original SQL statement

    When using row-based replication, the binary log does not contain SQL statements, only discrete single-row insert/update/delete events. This can make it harder to read mysqlbinlog output and understand where in an application a given event may have originated, complicating analysis and debugging.

    This feature adds an option to include the original SQL statement as a comment in the binary log (and shown in mysqlbinlog output) for row-based replication events.

    Row-based replication for tables with no primary key

    This feature can improve the performance of row-based replication on tables that do not have a primary key (or another unique key), but which do have another index that can help locate rows to update or delete. With this feature, index cardinality information from ANALYZE TABLE is considered when selecting the index to use (before this feature is implemented, the first index was selected unconditionally).

    PBXT consistent commit ordering

    This feature implements the new commit ordering storage engine API in PBXT. With this feature, it is possible to use START TRANSACTION WITH CONSISTENT SNAPSHOT and get consistency among transactions which involve both XtraDB and InnoDB. (Without this feature, there is no such consistency guarantee. For example, even after running START TRANSACTION WITH CONSISTENT SNAPSHOT it was still possible for the InnoDB/XtraDB part of some transaction T to be visible and the PBXT part of the same transaction T to not be visible.)

    Miscellaneous

    • This preview also includes a small change to make mysqlbinlog omit redundant use statements around BEGIN, SAVEPOINT, COMMIT, and ROLLBACK events when reading MySQL 5.0 binlogs.

    • The preview included a feature --innodb-release-locks-early. However, we decided to omit this feature from future MariaDB releases because of a fundamental design bug, lp:798213.

    This page is licensed: CC BY-SA / Gnu FDL

    download MariaDB 5.3 here
    MariaDB 5.3 tree on Launchpad

    Setting Up Replication

    Follow this step-by-step guide to configure standard replication. Learn how to prepare the primary, configure the replica, and establish a connection for data synchronization.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    Getting replication working involves steps on both the master server/s and steps on the replica server/s.

    Setting up a Replication Replica with MariaDB-Backup

    If you want to use to set up a replication replica, review the information under .

    Setting up replication the "traditional" way is covered below.

    Versions

    In general, when replicating across different versions of MariaDB, it is best that the master is an older version than the slave. MariaDB versions are usually backward compatible, while of course older versions cannot always be forward compatible. See also .

    Follow these steps to set up MariaDB replication:

    1

    Configure the Master

    • Enable binary logging if it's not already enabled. See and for details.

    • Give the master a unique . All slaves must also be given a server_id. This can be a number from 1 to 232-1, and must be unique for each server in the replicating group.

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    Unsafe Statements for Statement-Based Replication

    Identify SQL statements that are non-deterministic and unsafe for statement-based replication. Learn why these queries cause divergence and how to switch to row-based logging.

    A safe statement is generally deterministic; in other words the statement will always produce the same result. For example, an INSERT statement producing a random number will most likely produce a different result on the primary than on the replica, and so cannot be replicated safely.

    When an unsafe statement is run, the current binary logging format determines how the server responds.

    • If the binary logging format is statement-based, unsafe statements generate a warning and are logged normally.

    • If the binary logging format is mixed, unsafe statements are logged using the row-based format, while safe statements use the statement-based format.

    • If the binary logging format is , all statements are logged normally, and the distinction between safe and unsafe is not made.

    MariaDB tries to detect unsafe statements. When an unsafe statement is issued, a warning similar to the following is produced:

    MariaDB also issues this warning for some classes of statements that are safe.

    Unsafe Statements

    The following statements are regarded as unsafe:

    • statements using tables with multiple primary or unique keys, as the order that the keys are checked in, and which affect the rows chosen to update, is not deterministic. The warning about this was removed, because we always check keys in the same order on the primary and replica if the primary and replica are using the same storage engine.

    • . These statements are inserted in an indeterminate order.

    • for a table that has an column.

    Safe Statements

    The following statements are not deterministic, but are considered safe for binary logging and replication:

    Isolation Levels

    Even when using safe statements, not all are safe with statement-based or mixed binary logging. While the REPEATABLE READ and SERIALIZABLE isolation levels can be used with both statement- and row-based replication, the READ COMMITTED and READ UNCOMMITTED isolation levels only support row-based replication, as with them isolation between transactions is not guaranteed at all, and different transaction orders on a replica, or when doing point-in-time recovery, would lead to different results than on the original master.

    This restriction does not apply if only non-transactional storage engines are used.

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    START TRANSACTION ... WITH CONSISTENT SNAPSHOT

    Learn how to start a consistent transaction for backups or replication setup. This command ensures a consistent view of the database without locking tables unnecessarily.

    The START TRANSACTION WITH CONSISTENT SNAPSHOT statement begins a new transaction and, for the InnoDB storage engine, immediately establishes a consistent read view of the database.

    This differs from a standard START TRANSACTION or BEGIN statement, which creates its read view lazily only when the first read operation is performed. Using WITH CONSISTENT SNAPSHOT is essential for transactions where the snapshot's timing must be precisely aligned with the start of the transaction itself, not a later read query.

    Syntax

    START TRANSACTION and its alias BEGIN can be modified with one or more characteristics.

    For example:

    BEGIN WITH CONSISTENT SNAPSHOT; START TRANSACTION READ ONLY, WITH CONSISTENT SNAPSHOT;

    The InnoDB Read View

    MariaDB's InnoDB storage engine uses a mechanism called MVCC (Multi-Version Concurrency Control) to handle concurrent data access. A core component of MVCC is the read view.

    A read view can be thought of as an instantaneous snapshot of the database. When a transaction uses a read view, it sees only the data that was committed at the moment the "snapshot" was taken. It ignores any changes made by transactions that had not yet committed, as well as any changes from transactions that started after the read view was created.

    The key difference addressed by this command is the timing of this snapshot:

    Transaction Type
    Creation of Read View
    Time of Read View Creation

    Behavior with Transaction Isolation Levels

    The behavior of WITH CONSISTENT SNAPSHOT is dependent on the transaction isolation level.

    Isolation Level
    Default Read View Behavior
    Effect of WITH CONSISTENT SNAPSHOT

    With Default Read View Behavior

    Checking an Account Balance with a Transaction Delay

    In this situation, there is a delay in the application logic after initiating a transaction to check an account balance.

    Setup

    Scenario: Two sessions are running concurrently.

    Timeline
    Session 1 (Application checking balance)
    Session 2 (An external deposit)

    In the scenario above, the read view for Session 1 is created at T5. Since Session 2's COMMIT happened at T4, the SELECT in Session 1 will see the new balance: $1500.00. This might not be the desired behavior if the goal was to see the balance as it was at T1.

    With CONSISTENT SNAPSHOT

    Timeline
    Session 1 (Application checking balance)
    Session 2 (An external deposit)

    In this second scenario, the read view for Session 1 is created immediately at T1. Even though Session 2 commits a change at T4, the SELECT at T5 uses the original snapshot. It will see the old balance: $1000.00, reflecting the state of the database when the transaction began.

    Related System Variables

    innodb_snapshot_isolation

    This system variable influences the behavior of locking reads (for instance, SELECT ... FOR UPDATE). When is enabled (ON), locking reads reference the transaction's read view. If a transaction tries to lock a row modified by another transaction not visible in the current read view, MariaDB returns an ER_CHECKREAD error instead of waiting for a lock. This enforces stricter snapshot consistency, even for locking operations.

    Replication Threads

    Gain insight into the background threads that drive replication. Understand the roles of the I/O thread, SQL thread, and binlog dump thread in moving data between servers.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    MariaDB's replication implementation requires several types of threads.

    Threads on the Primary

    The primary usually only has one type of replication-related thread: the binary log dump thread.

    If is enabled, then the primary also has an ACK receiver thread.

    Binary Log Dump Thread

    The binary log dump thread runs on the primary and dumps the to the replica. This thread can be identified by running the statement and finding the thread where the is "Binlog Dump".

    The primary creates a separate binary log dump thread for each replica connected to the primary. You can identify which replicas are connected to the primary by executing the statement.

    Binary Log Dump Threads and the Shutdown Process

    When a primary server is shut down and it goes through the normal shutdown process, the primary kills client threads in random order. By default, the primary also considers its binary log dump threads to be regular client threads. As a consequence, the binary log dump threads can be killed while client threads still exist, and this means that data can be written on the primary during a normal shutdown that won't be replicated. This is true even if is being used. Data is not lost; it is stored in the primary server's binary log. The replicas on reconnection, after the primary server restarts, will resume at the exact position they were killed off during the primary shutdown. No data is lost.

    In and later, this problem can be solved by shutting down the server using either the utility or the command and providing a special option.

    For example, this problem can be solved by shutting down the server with the utility and by providing the --wait-for-all-slaves option to the utility and by executing the shutdown command with the utility:

    Or this problem can be solved by shutting down the server with the command and by providing the WAIT FOR ALL SLAVES option to the command:

    When one of these special options is provided, the server only kills its binary log dump threads after all client threads have been killed, and it only completes the shutdown after the last has been sent to all connected replicas.

    In and later, it is still not possible to enable this behavior by default. This means that this behavior is currently inaccessible when shutting down the server using tools like or .

    In and before, it is recommended to manually switchover replicas to a new primary before shutting down the old primary.

    ACK Receiver Thread

    When is enabled, semisynchronous replicas send acknowledgements (ACKs) to their primary to confirm that they have received some transaction. The primary creates an ACK receiver thread to receive these ACKs.

    Threads on the Replica

    The replica has three types of replication-related threads: the replica I/O thread, the replica SQL thread, and worker threads, which are only applicable when is in use.

    When is in use, each independent replication connection has its own replica threads of each type.

    Replica I/O Thread

    The replica's I/O thread receives the events from the primary and writes them to its .

    Binary Log Position

    The position of the replica's I/O thread can be checked by executing the statement. It will be shown as the Master_Log_File and Read_Master_Log_Pos columns.

    The position of the replica's I/O thread can be set by setting the and options with the statement.

    The position of the replica's I/O thread and the values of most other options are written to either the default master.info file or the file that is configured by the option. The replica's I/O thread keeps this position updated as it downloads events only when the option is set to NO. Otherwise the file is not updated on a per event basis. See for more information.

    Replica SQL Thread

    The replica's SQL thread reads events from the . What it does with them depends on whether is in use. If is not in use, then the SQL thread applies the events to its local copy of the data. If is in use, then the SQL thread hands off the events to its worker threads to apply in parallel.

    Relay Log Position

    The position of the replica's SQL thread can be checked by executing the statement. It will be shown as the Relay_Log_File and Relay_Log_Pos columns.

    The position of the replica's SQL thread can be set by setting the and options with the statement.

    The position of the replica's SQL thread is written to either the default relay-log.info file or the file that is configured by the system variable. The replica's SQL thread keeps this position updated as it applies events. See for more information.

    Binary Log Position

    The corresponding position of the current position of the replica's SQL thread can be checked by executing the statement. It will be shown as the Relay_Master_Log_File and Exec_Master_Log_Pos columns.

    GTID Position

    If the replica is replicating events that contain , then the will write every GTID that it applies to the table. This GTID can be inspected and modified through the system variable.

    If the replica has the system variable enabled and if the replica has the enabled, then every write by the will also go into the replica's . This means that of replicated transactions would be reflected in the value of the system variable.

    See for more information.

    Worker Threads

    When is in use, then the SQL thread hands off the events to its worker threads to apply in parallel.

    This page is licensed: CC BY-SA / Gnu FDL

    Multi-Master Ring Replication

    Explore the ring topology where each server acts as both primary and replica. Learn the configuration steps and caveats for setting up a circular replication environment.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

    wget -O- http://ftp.osuosl.org/pub/mariadb/PublicKey | sudo apt-key add -
    deb http://ftp.osuosl.org/pub/mariadb/mariadb-5.2-rpl/debian squeeze main
    deb-src http://ftp.osuosl.org/pub/mariadb/mariadb-5.2-rpl/debian squeeze main
    deb http://ftp.osuosl.org/pub/mariadb/mariadb-5.2-rpl/ubuntu maverick main
    deb-src http://ftp.osuosl.org/pub/mariadb/mariadb-5.2-rpl/ubuntu maverick main
    sudo apt-get update
    sudo apt-get install mariadb-server-5.2

    T5

    SELECT balance FROM accounts WHERE id = 1;

    T6

    COMMIT;

    T5

    SELECT balance FROM accounts WHERE id = 1;

    T6

    COMMIT;

    START TRANSACTION

    Created lazily

    At the first read operation (e.g., a SELECT)

    START TRANSACTION WITH CONSISTENT SNAPSHOT

    Created immediately

    At the moment the statement is executed, before other actions

    REPEATABLE READ

    A single, stable read view is created and used for the entire transaction.

    Guarantees the read view is established immediately at the start of the transaction.

    SERIALIZABLE

    Same as REPEATABLE READ

    Provides a predictable snapshot for all subsequent reads. This is its most common use case.

    READ COMMITTED

    A new read view is created for each individual SELECT statement.

    Affects the first read statement only, ensuring its snapshot is taken at the transaction's start time.

    READ UNCOMMITTED

    Does not use read views. Reads include uncommitted data ("dirty reads").

    T1

    START TRANSACTION;

    T2

    -- Application logic causes a 2-second delay DO SLEEP(2);

    START TRANSACTION;

    T3

    UPDATE accounts SET balance = 1500.00 WHERE id = 1;

    T4

    T1

    START TRANSACTION WITH CONSISTENT SNAPSHOT;

    T2

    -- Application logic causes a 2-second delay DO SLEEP(2);

    START TRANSACTION;

    T3

    UPDATE accounts SET balance = 1500.00 WHERE id = 1;

    T4

    innodb_snapshot_isolation

    Not permitted and has no effect.

    COMMIT;

    COMMIT;

    START TRANSACTION [transaction_characteristic [, transaction_characteristic] ...]
    
    transaction_characteristic:
        WITH CONSISTENT SNAPSHOT
      | READ WRITE | READ ONLY
      | [NOT] CHAIN
    CREATE TABLE accounts (
        id INT PRIMARY KEY,
        balance DECIMAL(10, 2)
    ) ENGINE=InnoDB;
    
    INSERT INTO accounts VALUES (1, 1000.00);
    Specify a unique name for your replication logs with --log-basename. If this is not specified your host name will be used and there will be problems if the hostname ever changes.
  • Slaves will need permission to connect and start replicating from a server. Usually this is done by creating a dedicated slave user, and granting that user permission only to replicate (REPLICATION SLAVE permission).

  • Example Enabling Replication for MariaDB

    Add the following into your my.cnf file and restart the database.

    The server id is a unique number for each MariaDB/MySQL server in your network.binlog-format specifies how your statements are logged. This mainly affects the size of the binary log that is sent between the Master and the Replicas.

    Then execute the following SQL with the mysql command line client:

    Example Enabling Replication for MySQL

    If you want to enable replication from MySQL 5.7 or earlier to MariaDB, you can do it in almost the same way as between MariaDB servers. The main difference is that MySQL doesn't support log-basename.

    Replication from MySQL 8.0 to MariaDB .

    2

    Check Settings

    There are a number of options that may impact or break replication. Check the following settings to avoid problems.

    • skip-networking. If skip-networking=1, the server will limit connections to localhost only, and prevent all remote replicas from connecting.

    • bind-address. Similarly, if the address the server listens for TCP/IP connections is 127.0.0.1 (localhost), remote replica connections will fail.

    3

    Configure the Replica

    Give the replica a unique server_id. All servers, whether masters or replicas, are given a server_id. This can be a number from 1 to 232-1, and must be unique for each server in the replicating group. The server will need to be restarted in order for a change in this option to take effect.

    4

    Get the Master's Binary Log Coordinates

    Now you need prevent any changes to the data while you view the binary log position. You'll use this to tell the replica at exactly which point it should start replicating from.

    • On the master, flush and lock all tables by running FLUSH TABLES WITH READ LOCK. Keep this session running - exiting it will release the lock.

    • Get the current position in the binary log by running SHOW MASTER STATUS:

    • Record the File and Position details. If binary logging has just been enabled, these will be blank.

    • Now, with the lock still in place, copy the data from the master to the replica. See for details on how to do this.

    • Note for live databases: You just need to make a local copy of the data, you don't need to keep the master locked until the replica has imported the data.

    • Once the data has been copied, you can release the lock on the master by running .

    5

    Start the Replica

    • Once the data has been imported, you are ready to start replicating. Begin by running a CHANGE MASTER TO, making sure that MASTER_LOG_FILE matches the file and MASTER_LOG_POS the position returned by the earlier SHOW MASTER STATUS:

    If you are starting a replica against a fresh master that was configured for replication from the start, then you don't have to specify MASTER_LOG_FILE and MASTER_LOG_POS.

    Use Global Transaction ID (GTID)

    It is generally recommended to use (GTIDs), as it has a number of benefits. All that is needed is to add the MASTER_USE_GTID option to the CHANGE MASTER statement:

    See for a full description.

    • Now start the replica with the statement:

    • Check that the replication is working by executing the command:

    • If replication is working correctly, both the values of Slave_IO_Running and Slave_SQL_Running should be Yes:

    Replicating from MySQL Master to MariaDB Replica

    • Replicating from MySQL 5.5 to MariaDB should just work. When using a MariaDB as a replica, it may be necessary to set to NONE.

    • Replicating from MySQL 5.6 without GTID to MariaDB 10+ should work.

    • Replication from MySQL 5.6 with GTID, binlog_rows_query_log_events and ignorable events works. In this case MariaDB will remove the MySQL GTIDs and other unneeded events and instead adds its own GTIDs.

    requires or newer.

    Global Transaction ID
  • Parallel Replication

  • Replication and Binary Log System Variables

  • Replication and Binary Log Status Variables

  • Semisynchronous Replication

  • Delayed Replication

  • mariadb-backup
    Setting up a Replication Replica with MariaDB-Backup
    Replicating from MySQL Master to MariaDB Replica
    Activating the Binary Log
    Binary log formats
    server_id
    Differences between Statement-based, mixed and row logging
    Replication and Foreign Keys
    Replication as a Backup Solution
    Multi-source Replication
    on tables with a composite primary key that has an
    column that isn't the first column of the composite key.
  • When a table has an AUTO_INCREMENT column and a trigger or stored procedure executes an UPDATE statement against the table.

  • UPDATE statements that use LIMIT, since the order of the returned rows is unspecified. This applies even to statements using an ORDER BY clause, which are deterministic (a known bug). However, LIMIT 0 is an exception to this rule (see MDEV-6170), and these statements are safe for replication.

  • When using a user-defined function.

  • Statements using any of the following functions, which can return different results on the replica:

    • CURRENT_ROLE()

    • CURRENT_USER()

    • FOUND_ROWS()

    • .

  • Statements which refer to log tables, since these may differ across servers.

  • Statements which refer to self-logging tables. Statements following a read or write to a self-logging table within a transaction are also considered unsafe.

  • Statements which refer to system variables (there are a few exceptions).

  • LOAD DATA INFILE statements.

  • Non-transactional reads or writes that execute after transactional reads within a transaction.

  • If row-based logging is used for a statement, and the session executing the statement has any temporary tables, row-based logging is used for the remaining statements until the temporary table is dropped. This is because temporary tables can't use row-based logging, so if it is used due to one of the above conditions, all subsequent statements using that table are unsafe. The server deals with this situation by treating all statements in the session as unsafe for statement-based logging until the temporary table is dropped.

  • CURRENT_TIMESTAMP()
  • CURTIME()

  • LAST_INSERT_ID()

  • LOCALTIME()

  • LOCALTIMESTAMP()

  • NOW()

  • UNIX_TIMESTAMP()

  • UTC_DATE()

  • UTC_TIME()

  • UTC_TIMESTAMP()

  • row-based
    INSERT ... ON DUPLICATE KEY UPDATE
    INSERT-DELAYED
    INSERT ... SELECT
    AUTO_INCREMENT
    CONNECTION_ID()
    CURDATE()
    CURRENT_DATE()
    CURRENT_TIME()
    transaction isolation levels
    Replication and Foreign Keys
    Replicating Temporary Tables
    INSERTs
    AUTO_INCREMENT
    What is Multi-Master Ring Replication

    Multi-Master "Ring" Replication means that you have two or more masters where each master is replicating its data to another master asynchronously. This is not to be confused with MariaDB Galera Cluster which is a multi-primary cluster for MariaDB.

    The benefit of asynchronous replication compared to Galera Cluster, is that Ring Replication is resilient against bad network connections between the master servers. If a connection goes down, all masters will continue to serve its clients locally and data will automatically be synced when the link is available again.

    The following picture shows one of the more advanced Multi-Master setups that is resilient against any master going down but can also handle 'human failures', like an accidental drop table, thanks to the addition of delayed slaves.

    One should setup replication on each master like one does in standard MariaDB replication. The replication setup among the masters should be a ring. In other words, each master should replicate to one other master and each master should only have one other master as a slave.

    Each master can of course have one or more normal slaves. A master could also be a slave of another master that is not in the ring setup.

    All MariaDB servers support Multi-Master Ring Replication. In fact, when MySQL replication was originally designed around the year 2000, it was to be a Multi-Master Ring Replication solution for Yahoo to replicate from the East Coast to the West Coast.

    Configuring the Masters

    First, follow the instructions in setup replication. The main thing to remember is to use the master_use_gtid=current_pos option for CHANGE MASTER.

    The main things that are different for Multi-Master Ring Replication are:

    • Give every master and slave in the replication setup a unique server_id. This can be a number from 1 to 4294967295 or 1-255 if one is using uuid_short(). It is a good practice to ensure that you do not have any servers in your system with the same server_id!

    • Use global transaction id (as described above)

    • Give each master a unique gtid_domain_id. This will allow replication to apply transactions from a different master in parallel independent from other masters.

    Add the following into your my.cnf file for all masters and restart the servers.

    Limitations when using Ring Replication

    • MariaDB does not yet support conflict resolution for conflicting changes. It is up to the application to ensure that there is never a conflicting insert/update/delete between the masters. The easiest setup is having each master server work on a different database or table. If not, one must:

      • Ensure you have an id (master-unique-id) for each row that unequally identifies the master who is responsible for this row. This should preferably be short and part of the primary key in each table. A good value for this would be the gtid_domain_id as this is unique for each local cluster.

      • Never insert rows with PRIMARY KEY or UNIQUE KEY values that can be same on another master. This can be avoided by

        • Have the master-unique-id part of all primary and unique keys.

        • In case of AUTO_INCREMENT keys, have a different value for on each master.

        • Use to generate unique values, like in create table t1 (a bigint unsigned default(uuid_short()) primary key). Note that if one is using in Multi-Master ring replication, one can only use server_id in the range 1-255!

      • Ensure that and on each master only update rows generated by this master.

    • If several masters are constantly generating and updating rows for common tables, one has to be extra careful with ALTER TABLE to ensure that any change one does will not cause conflicts when the ALTER TABLE is replicated to other servers. In particular one has to ensure that all masters and their slaves are configured with slave_type_conversions=ALL_NON_LOSSY,ALL_LOSSY.

    • The server_id should be unique for each server. One should not change the server_id of an active master, as the ID is used by the master to recognize its own events and stop them from replicating endlessly around the ring (see ).

    How does Multi-Master Ring Replication work

    • The main difference between Multi-Master Ring Replication and normal replication is that a change done by a master will eventually replicate back to it. When this happens, the master will see that the binary log event has the same server_id as the master has and will ignore the event. This is why it is critical to ensure that all server_id's are unique and that one does not change the server id.

    • When doing ALTER TABLE in a Multi-Master Ring replication setup, you should be aware the while you are running an ALTER TABLE on one master, another master can generate events that uses the old table definition. You should especially take care to not drop columns that could be in use by any application or still available in the upcoming replication stream.

    How to resolve things if they go wrong in Multi-Master Ring Replication

    When used correctly, Multi-Master Ring Replication is as resilient to errors as normal MariaDB master-slave replication. If the connection goes down, the replication will stop and will automatically continue when the connection resumes.

    What to do when one of the masters dies and has to be replaced by a slave.

    • Ensure that the slave is up to date (has digested all relay events).

    • Check if there are any events on the old master that have not been sent to the slave. You can use mariadb-binlog to read the old master binary log files and apply them to the slave.

    • You can now treat the slave as a new master and put it back in the replication ring. The new master will use its replication GTID position to continue replication from the other master in the ring.

    If the slave is not up to date and one cannot access any information of the old master, then one can continue the following way:

    • Enable the option --gtid-ignore-duplicates on the servers.

    • Add the slave to the replication ring.

    • The two masters (one of which is the old slave now added to the ring) will each replicate the events they are missing from one another. The --gtid-ignore-duplicates option is needed to allow the two masters in the ring to start replicating from each other when each server is ahead of the other in one domain and behind in another.

    Error applying events

    As long as each master handles their own set of data, as described above, there should not be any conflicting data coming from the other master.

    If there are conflicts, one should resolve them as one resolves issues with normal replication. The most common way to solve issues is to skip the conflicting log events with SET GLOBAL SQL_SLAVE_SKIP_COUNTER.

    Handling duplicate key errors and other conflicts

    If things are setup correctly as described earlier, one should never get duplicate key errors in Multi-Master ring replication. Any duplicate key error or data mismatch is usually an application error where it inserts/updates or deletes something it should not have the right to do.

    To fix this:

    • Use SET GLOBAL SQL_SLAVE_SKIP_COUNTER to skip the error.

    • Use `mariadb-binlog --base64-output=decode-rows --verbose --start-position=

    binlog-name` to see what is missing and apply the changes missing on the server (minus the conflict).

    Multi-Master Ring Replication through slaves

    An alternative setup to use for Multi-master ring replications is to replicate to the other masters through slaves. The following setup shows how this can be done.

    Benefits of replication through slaves

    • The slave will never be out of sync compared to other master. This makes failover from master to slave much easier as one does not have to check if slave has all data.

    • Slightly less load on the master

    • One can use semisynchronous-replication between master and slave.

    • Slave configuration is consolidated to one place. That is, if a master's immediate slave and replicating master should share the same configuration (e.g. rewrite rules, filters, etc), only the immediate slave needs them configured, as the replicating master will pull in the effects inherently.

    Disadvantages of replication through slaves

    • There will be a slightly longer delay for the data to hit the next master as it has to go trough the slave. This can be notable if there is a very large transaction executed on the master.

    • If the master OR the slave dies, the replication to other masters will stop.

    • A replicating master is subject to the configuration of a slave (e.g. transactions may be incorrectly filtered out).

    • Re-setting replication after failover is a bit more complex.

    Setting things up

    • Setup is identical to Multi-Master Ring Replication, except that rpl_semi_sync_master_enabled=0 is not required.

    What to do when one of the masters dies and has to be replaced by a slave.

    Let assume that master1 in the above picture has failed.

    What needs to be done is to replace master1 with slave1 and add a new slave to replace slave1. Here follows a step by step description of how to do this.

    The new slave that will be added to replace slave1 place will below be called slave3. The new master will be called master3 (to simplify explanations). Note that in some cases, the failed master can be re-used as the new slave if it did recover properly. If this is the case, reset all replications setups on the failed master.

    Note that when one sets up a master->slave replication, all configurations are done only on the slave!

    • Promote slave1 as the new master3. Applications should now be moved to use master3. Note MaxScale can do this step automatically.

    • Setup master3 as a slave of slave2.

      • The ring replication is now active (at least temporarily, until we have slave3 in place).

    • Delete the old replication setup in master3 that pointed to the deleted master1.

    • Prepare the new slave3 (which can take a while if it based on a backup of master3).

    • Setup slave3 as a slave of master3.

    • If delayed slave1 exists, redirect it to be a slave of slave3.

    • Update master2 to be slave of slave3 (from being a slave of master3).

    Some other options:

    • For semi-sync setups, the old master1 can be re-used as slave3 if re-started with --init-rpl-role=SLAVE during recovery

    • For non-semi-synchronous setups, one can use option CHANGE MASTER TO MASTER_DEMOTE_TO_SLAVE=1 (requires MariaDB 10.11 or higher).

    See also

    • Multi-source replication

    This page is licensed: CC BY-SA / Gnu FDL

    MDEV-18777
    semisynchronous replication
    binary log
    SHOW PROCESSLIST
    thread command
    SHOW SLAVE HOSTS
    semi-synchronous replication
    mariadb-admin
    SHUTDOWN
    mariadb-admin
    SHUTDOWN
    binary log
    systemd
    sysVinit
    semisynchronous replication
    parallel replication
    multi-source replication
    binary log
    relay log
    binary log
    SHOW SLAVE STATUS
    binary log
    MASTER_LOG_FILE
    MASTER_LOG_POS
    CHANGE MASTER
    binary log
    CHANGE MASTER
    master_info_file
    binary log
    MASTER_USE_GTID
    CHANGE MASTER TO: Option Persistence
    relay log
    parallel replication
    parallel replication
    parallel replication
    relay log
    SHOW SLAVE STATUS
    relay log
    RELAY_LOG_FILE
    RELAY_LOG_POS
    CHANGE MASTER
    relay log
    relay_log_info_file
    relay log
    CHANGE MASTER TO: Option Persistence
    binary log
    relay log
    SHOW SLAVE STATUS
    binary log
    GTIDs
    replica's's SQL thread
    mysql.gtid_slave_pos
    gtid_slave_pos
    log_slave_updates
    binary log
    replica's SQL thread
    binary log
    GTIDs
    gtid_binlog_pos
    CHANGE MASTER TO: GTID Persistence
    parallel replication
    SHOW MASTER STATUS;
    +--------------------+----------+--------------+------------------+
    | File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +--------------------+----------+--------------+------------------+
    | master1-bin.000096 |      568 |              |                  |
    +--------------------+----------+--------------+------------------+
    CHANGE MASTER TO
      MASTER_HOST='master.domain.com',
      MASTER_USER='replication_user',
      MASTER_PASSWORD='bigs3cret',
      MASTER_PORT=3306,
      MASTER_LOG_FILE='master1-bin.000096',
      MASTER_LOG_POS=568,
      MASTER_CONNECT_RETRY=10;
    [mariadb]
    log-bin
    server_id=1
    log-basename=master1
    binlog-format=mixed
    CREATE USER 'replication_user'@'%' IDENTIFIED BY 'bigs3cret';
    GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
    [mysqld]
    log-bin
    server_id=1
    Note (Code 1592): Unsafe statement written to the binary log using statement format since 
      BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This 
      is unsafe because the set of rows included cannot be predicted.
    [mariadb]
    # Replace the following with a unique ID. All slaves of this master should have the same
    # gtid_domain_id to allow easy failover to a slave if needed
    gtid_domain_id=1
    #
    # Let us assume there will never be more than 10 masters in a Multi-Master ring setup
    auto_increment_increment=10
    # Set this to a different value 1-10 for each master. Could be the same as gtid_domain_id
    # This is to ensure that all masters generate different values for AUTO_INCREMENT keys.
    auto_increment_offset=1
    #
    # The following is needed to ensure the ALTER TABLE on another master will not
    # break ring replication
    slave_type_conversions=ALL_NON_LOSSY,ALL_LOSSY
    #
    # We cannot use semi-sync in Ring Replication as the masters need to be resilient against
    # bad connections
    rpl_semi_sync_master_enabled=0
    #
    # We have to log updates from other masters to the binary log.
    log_slave_updates
    mariadb-admin --wait-for-all-slaves shutdown
    SHUTDOWN WAIT FOR ALL SLAVES;
    GET_LOCK()
    IS_FREE_LOCK()
    IS_USED_LOCK()
    JSON_TABLE()
    LOAD_FILE()
    MASTER_POS_WAIT()
    RAND()
    RANDOM_BYTES()
    RELEASE_ALL_LOCKS()
    RELEASE_LOCK()
    ROW_COUNT()
    SESSION_USER()
    SLEEP()
    SYSDATE()
    SYSTEM_USER()
    USER()
    UUID()
    UUID_SHORT()
    Backup, Restore and Import
    UNLOCK TABLES
    Global Transaction ID
    START REPLICA
    SHOW SLAVE STATUS
    binlog_checksum
    MariaDB 11.4.5
    auto_increment_offset
    uuid_short()
    uuid_short()
    UPDATE
    DELETE
    replicate_same_server_id

    Running Triggers on the Replica for Row-based Events

    Understand how triggers behave under row-based replication. Learn when and why triggers are not executed on the replica and how to manage complex logic in this mode.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    MariaDB can force the replica thread to run triggers for row-based binlog events.

    The setting is controlled by the slave_run_triggers_for_rbr global variable. It can be also specified as a command-line option or in my.cnf.

    Possible values are:

    Value
    Meaning

    Note that if you just want to use triggers together with replication, you most likely don't need this option. Read below for details.

    When to Use slave_run_triggers_for_rbr

    Background

    Normally, MariaDB's replication system can replicate trigger actions automatically.

    • When one uses statement-based replication, the binary log contains SQL statements. Replica server(s) execute the SQL statements. Triggers are run on the master and on each replica, independently.

    • When one uses row-based replication, the binary log contains row changes. It will have both the changes made by the statement itself, and the changes made by the triggers that were invoked by the statement. Replica server(s) do not need to run triggers for row changes they are applying.

    Target Usecase

    One may want to have a setup where a replica has triggers that are not present on the master (Suppose the replica needs to update summary tables or perform some other ETL-like process).

    If one uses statement-based replication, they can just create the required triggers on the replica. The replica will run the statements from the binary log, which will cause the triggers to be invoked.

    However, there are cases where you have to use row-based replication. It could be because the master runs non-deterministic statements, or the master could be a node in a Galera cluster. In that case, you would want row-based events to invoke triggers on the replica. This is what the slave_run_triggers_for_rbr option is for. Setting the option to YES will cause the SQL replica thread to invoke triggers for row-based events; setting it to LOGGING will also cause the changes made by the triggers to be written into the binary log.

    The following triggers are invoked:

    • Update_row_event runs an UPDATE trigger

    • Delete_row_event runs a DELETE trigger

    • Write_row_event runs an INSERT trigger. Additionally it runs a DELETE trigger if there was a conflicting row that had to be deleted.

    Preventing Multiple Trigger Invocations

    There is a basic protection against triggers being invoked both on the master and replica. If the master modifies a table that has triggers, it will produce row-based binlog events with the "triggers were invoked for this event" flag. The replica will not invoke any triggers for flagged events.

    See Also

    • Task in Jira, .

    This page is licensed: CC BY-SA / Gnu FDL

    Replication and Binary Log Status Variables

    View the status variables used to monitor replication health. Learn how to interpret metrics regarding log positions, connection status, and event counts.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

    The following status variables are useful in and . See for a complete list of status variables that can be viewed with .

    See also the .

    UNLOCK TABLES;
    CHANGE MASTER TO MASTER_USE_GTID = slave_pos
    START REPLICA;
    SHOW REPLICA STATUS \G
    Slave_IO_Running: Yes
    Slave_SQL_Running: Yes

    Obsolete Replication Information

    Access documentation for deprecated or removed replication features. Review this historical context when upgrading legacy systems or migrating to newer MariaDB versions.

    virtually synchronous
    Binlog_bytes_written
    • Description: The number of bytes written to the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_cache_disk_use

    • Description: Number of transactions which used a temporary disk cache because they could not fit in the regular binary log cache, being larger than binlog_cache_size. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Binlog_cache_use

    • Description: Number of transaction which used the regular binary log cache, being smaller than binlog_cache_size. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Binlog_commits

    • Description: Total number of transactions committed to the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_disk_use

    • Description: If max-binlog-total_size is not set to zero, shows the space usage of the binary log in bytes.

    • Scope: Global

    • Data Type: numeric

    • Introduced: MariaDB 11.4

    Binlog_group_commit_trigger_count

    • Description: Total number of group commits triggered because of the number of binary log commits in the group reached the limit set by the variable binlog_commit_wait_count. See Group commit for the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_group_commit_trigger_lock_wait

    • Description: Total number of group commits triggered because a binary log commit was being delayed because of a lock wait where the lock was held by a prior binary log commit. When this happens the later binary log commit is placed in the next group commit. See Group commit for the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_group_commit_trigger_timeout

    • Description: Total number of group commits triggered because of the time since the first binary log commit reached the limit set by the variable binlog_commit_wait_usec. See Group commit for the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_group_commits

    • Description: Total number of group commits done to the binary log. See Group commit for the binary log.

    • Scope: Global

    • Data Type: numeric

    Binlog_gtid_index_hit

    • Description: Incremented for each successful lookup in a GTID index.

    • Scope: Global

    • Data Type: numeric

    • Introduced: MariaDB 11.4

    Binlog_gtid_index_miss

    • Description: Incremented when a GTID index lookup is not possible, which indicates that the index file is missing (eg. binlog written by old server version without GTID index support), or corrupt.

    • Scope: Global

    • Data Type: numeric

    • Introduced: MariaDB 11.4

    Binlog_snapshot_file

    • Description: The binary log file. Unlike SHOW MASTER STATUS, can be queried in a transactionally consistent way, irrespective of which other transactions have been committed since the snapshot was taken. See Enhancements for START TRANSACTION WITH CONSISTENT SNAPSHOT.

    • Scope: Global

    • Data Type: string

    Binlog_snapshot_position

    • Description: The binary log position. Unlike SHOW MASTER STATUS, can be queried in a transactionally consistent way, irrespective of which other transactions have been committed since the snapshot was taken. See Enhancements for START TRANSACTION WITH CONSISTENT SNAPSHOT.

    • Scope: Global

    • Data Type: numeric

    Binlog_stmt_cache_disk_use

    • Description: Number of non-transaction statements which used a temporary disk cache because they could not fit in the regular binary log cache, being larger than binlog_stmt_cache_size. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Binlog_stmt_cache_use

    • Description: Number of non-transaction statement which used the regular binary log cache, being smaller than binlog_stmt_cache_size. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Com_change_master

    • Description: Number of CHANGE MASTER TO statements executed.

    • Scope: Global, Session

    • Data Type: numeric

    Com_show_binlog_status

    • Description:

    • Scope: Global, Session

    • Data Type: numeric

    • Introduced:

    Com_show_master_status

    • Description: Number of SHOW MASTER STATUS commands executed.

    • Scope: Global, Session

    • Data Type: numeric

    • Removed:

    Com_show_new_master

    • Description:

    • Scope: Global, Session

    • Data Type: numeric

    • Removed:

    Com_show_slave_hosts

    • Description: Number of SHOW SLAVE HOSTS commands executed.

    • Scope: Global, Session

    • Data Type: numeric

    Com_show_slave_status

    • Description: Number of SHOW SLAVE STATUS commands executed.

    • Scope: Global, Session

    • Data Type: numeric

    Com_slave_start

    • Description: Number of START SLAVE commands executed. Removed in , see Com_start_slave.

    • Scope: Global, Session

    • Data Type: numeric

    • Removed:

    Com_slave_stop

    • Description: Number of STOP SLAVE commands executed. Removed in , see Com_stop_slave.

    • Scope: Global, Session

    • Data Type: numeric

    • Removed:

    Com_start_all_slaves

    • Description: Number of START ALL SLAVES commands executed.

    • Scope: Global, Session

    • Data Type: numeric

    Com_start_slave

    • Description: Number of START SLAVE commands executed. Replaces the old Com_slave_start.

    • Scope: Global, Session

    • Data Type: numeric

    Com_stop_all_slaves

    • Description: Number of STOP ALL SLAVES commands executed.

    • Scope: Global, Session

    • Data Type: numeric

    Com_stop_slave

    • Description: Number of STOP SLAVE commands executed. Replaces the old Com_slave_stop.

    • Scope: Global, Session

    • Data Type: numeric

    Master_gtid_wait_count

    • Description: Number of times MASTER_GTID_WAIT called.

    • Scope: Global, Session

    • Data Type: numeric

    Master_gtid_wait_time

    • Description: Total number of time spent in MASTER_GTID_WAIT.

    • Scope: Global, Session

    • Data Type: numeric

    Master_gtid_wait_timeouts

    • Description: Number of timeouts occurring in MASTER_GTID_WAIT.

    • Scope: Global, Session

    • Data Type: numeric

    Rpl_status

    • Description: For showing the status of fail-safe replication. Removed in MySQL 5.6, still present in .

    Rpl_transactions_multi_engine

    • Description: Number of replicated transactions that involved changes in multiple (transactional) storage engines, before considering the update of mysql.gtid_slave_pos. These are transactions that were already cross-engine, independent of the GTID position update introduced by replication. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Slave_connections

    • Description: Number of REGISTER_SLAVE attempts. In practice the number of times slaves has tried to connect to the master.

    • Scope: Global

    • Data Type: numeric

    Slave_heartbeat_period

    • Description: Time in seconds that a heartbeat packet is requested from the master by a slave.

    • Scope: Global

    • Data Type: numeric

    Slave_open_temp_tables

    • Description: Number of temporary tables the slave has open.

    • Scope: Global

    • Data Type: numeric

    Slave_received_heartbeats

    • Description: Number of heartbeats the slave has received from the master.

    • Scope: Global

    • Data Type: numeric

    Slave_retried_transactions

    • Description: Number of times the slave has retried transactions since the server started. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Slave_running

    • Description: Whether the default connection slave is running (both I/O and SQL threads are running) or not.

    • Scope: Global

    • Data Type: numeric

    Slave_skipped_errors

    • Description: The number of times a slave has skipped errors defined by slave-skip-errors.

    • Scope: Global

    • Data Type: numeric

    Slaves_connected

    • Description: Number of slaves connected.

    • Scope: Global

    • Data Type: numeric

    Slaves_running

    • Description: Number of slave SQL threads running.

    • Scope: Global

    • Data Type: numeric

    Transactions_gtid_foreign_engine

    • Description: Number of replicated transactions where the update of the gtid_slave_pos table had to choose a storage engine that did not otherwise participate in the transaction. This can indicate that setting gtid_pos_auto_engines might be useful. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    Transactions_multi_engine

    • Description: Number of transactions that changed data in multiple (transactional) storage engines. If this is significantly larger than Rpl_transactions_multi_engine, it indicates that setting gtid_pos_auto_engines could reduce the need for cross-engine transactions. The global value can be flushed by FLUSH STATUS.

    • Scope: Global

    • Data Type: numeric

    This page is licensed: CC BY-SA / Gnu FDL

    MDEV-18777
    binary logging
    replication
    Server Status Variables
    SHOW STATUS
    Full list of MariaDB options, system and status variables

    NO (Default)

    Don't invoke triggers for row-based events

    YES

    Invoke triggers for row-based events, don't log their effect into the binary log

    LOGGING

    Invoke triggers for row-based events, and log their effect into the binary log

    ENFORCE

    From only. Triggers will always be run on the replica, even if there are triggers on the master. ENFORCE implies LOGGING.

    MDEV-5095

    Multi-Source Replication

    Discover how to replicate data from multiple primaries to a single replica. This guide covers the configuration for aggregating data from different sources into one MariaDB instance.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see to follow progress on this effort.

    Multi-source replication means that one server has many primaries from which it replicates.

    virtually synchronous
    New Syntax

    You specify which primary connection you want to work with by either specifying the connection name in the command or setting default_master_connection to the connection you want to work with.

    The connection name may include any characters and should be less than 64 characters. Connection names are compared without regard to case (case insensitive). You should preferably keep the connection name short, as it will be used as a suffix for relay logs and primary info index files.

    The new syntax was introduced to handle many connections:

    • CHANGE MASTER ['connection_name'] TO .... This creates or modifies a connection to a primary.

    • FLUSH RELAY LOGS ['connection_name']

    • MASTER_POS_WAIT(....,['connection_name'])

    • [RESET SLAVE ['connection_name'] [ALL] This is used to reset a replica's replication position or to remove a replica permanently.

    The original old-style connection is an empty string ''. You don't have to use this connection if you don't want to.

    You create new primary connections with CHANGE MASTER. You delete the connection permanently with RESET SLAVE 'connection_name' ALL.

    Replication Variables for Multi-Source

    The new replication variable default_master_connection specifies which connection will be used for commands and variables if you don't specify a connection. By default, this is '' (the default connection name).

    The following replication variables are local for the connection. (In other words, they show the value for the@@default_master_connection connection). We are working on making all the important ones local for the connection.

    Type
    Name
    Description

    Variable

    Max size of relay log. Is set at startup to max_binlog_size if 0

    Variable

    Tell the replica to restrict replication to updates of tables whose names appear in the comma-separated list. For statement-based replication, only the default database (that is, the one selected by USE) is considered, not any explicitly mentioned tables in the query. For row-based replication, the actual names of the table(s) being updated are checked.

    Variable

    Tells the replica to restrict replication to tables in the comma-separated list.

    Variable

    Tell the replica to restrict replication to updates of tables whose names do not appear in the comma-separated list. For statement-based replication, only the default database (that is, the one selected by USE) is considered, not any explicitly mentioned tables in the query. For row-based replication, the actual names of the table(s) being updated are checked.

    You can access all of the above variables with either SESSION or GLOBAL.

    Note that in contrast to MySQL, all variables always show the correct active value!

    Example:

    If @@default_master_connection contains a non existing name, you will get a warning.

    All other primary-related variables are global and affect either only the '' connections or all connections. For example, Slave_retried_transactions now shows the total number of retried transactions over all replicas.

    If you need to set gtid_slave_pos, you need to set this for all primaries at the same time.

    New status variables:

    Name
    Description

    Number of executed START ALL SLAVES commands.

    Number of executed START SLAVE commands. This replaces Com_slave_start.

    Number of executed STOP SLAVE commands. This replaces Com_slave_stop.

    Number of executed STOP ALL SLAVES commands.

    SHOW ALL SLAVES STATUS has the following new columns:

    Name
    Description

    Connection_name

    Name of the primary connection. This is the first variable.

    Slave_SQL_State

    State of SQL thread.

    Retried_transactions

    Number of retried transactions for this connection.

    Max_relay_log_size

    Max relay log size for this connection.

    Executed_log_entries

    How many log entries the replica has executed.

    Slave_received_heartbeats

    How many heartbeats we have got from the primary.

    New Files

    The basic principle of the new files used by multi-source replication is that they have the same name as the original relay log files, suffixed with connection_name before the extension. The main exception is that the file that holds all connections is named as the normal master-info-file with a multi- prefix.

    When you are using multi-source, the following new files are created:

    Name
    Description

    multi-master-info-file

    The master-info-file (normally master.info) with a multi- prefix. This contains all primary connections in use.

    master-info-file-connection_name.extension

    Contains the current primary position for what's applied to in the replica. Extension is normally .info

    relay-log-connection_name.xxxxx

    The relay-log name with a connection_name suffix. The xxxxx is the relay log number. This contains the replication data read from the primary.

    relay-log-index-connection_name.extension

    Contains the name of the active relay-log-connection_name.xxxxx files. Extension is normally .index

    relay-log-info-file-connection_name.extension

    Contains the current primary position for the relay log. Extension is normally .info

    When creating the file, the connection name is converted to lowercase, and all special characters in the connection name are converted, the same way as MySQL table names are converted. This is done to make the file name portable across different systems.

    Hint:

    Instead of specifying names for mysqld with --relay-log, --relay-log-index, --general-log-file, --slow-query-log-file,--log-bin, and --log-bin-index, you can just specify --log-basename, and all the other variables are set with this as a prefix.

    Other Things

    • All error messages from a replica with a connection name that are written to the error log are prefixed with Master 'connection_name':. This makes it easy to see from where an error originated.

    • Errors ER_MASTER_INFO and WARN_NO_MASTER_INFO now includes connection_name.

    • There is no conflict resolution. The assumption is that there are no conflicts in data between the different primaries.

    • All executed commands are stored in the normal binary log (nothing new here).

    • If the server variable log_warnings > 1, then you will get some information in the log about how the multi-master-info file is updated (mainly for debugging).

    • The output of has one more column than SHOW SLAVE STATUS, since it includes the connection_name column.

    • now deletes all relay-log files.

    replicate-... Variables

    • One can set the values for the replicate-... variables from the command line or in my.cnf for a given connection by prefixing the variable with the connection name.

    • If one doesn't use any connection name prefix for a replicate.. variable, then the value will be used as the default value for all connections that don't have a value set for this variable.

    Example:

    This sets the replicate_do_db variable to main_database for the connection named main_connection. All other connections will use the value other_database.

    One can also use this syntax to set replicate-rewrite-db for a given connection.

    Typical Use Cases

    • You are partitioning your data over many primaries and would like to get it all together on one machine to do analytical queries on all the data.

    • You have many databases spread over many MariaDB/MySQL servers and would like to have all of them on one machine as an extra backup.

    • In a Galera cluster, the default replication filter rules, like replicate-do-db, do not apply to replication connections, but also to Galera write set applier threads. By using a named multi-primary replication connection instead, even when replicating from just one primary into the cluster, the primary-replica replication rules can be kept separate from the Galera intra-node replication traffic.

    Limitations

    • Each active connection will create 2 threads (as is normal for MariaDB replication).

    • You should ensure that all primaries have different server-id's. If you don't do this, you will get into trouble if you try to replicate from the multi-source replica back to your primaries.

    • One can change max_relay_log_size for any active connection, but new connections will always use the server startup value for max_relay_log_size, which can't be changed at runtime.

    • Option (xtradb feature to store and restore relay log position for replicas) only works for the default connection ''. As this option is not really safe and can easily cause loss of data if you use storage engines other than InnoDB, we don't recommend using this option.

    • affects all connections. We don't check anymore if it's less than , as this doesn't make sense in a multi-source setup.

    Incompatibilities with MariaDB/MySQL 5.5

    • max_relay_log_size is now (almost) a normal variable and not automatically changed if max_binlog_size is changed. To keep things compatible with old config files, we set it to max_binlog_size at startup if its value is 0.

    • You can now access replication variables that depend on the active connection with either GLOBAL or SESSION.

    • We only write information about relay log positions for recovery if innodb-recovery-update-relay-log is set.

    • now shows the total count of retried transactions over all replicas.

    • The status variable Com_slave_start is replaced with .

    • The status variable Com_slave_stop is replaced with .

    • FLUSH RELAY LOGS are not replicated anymore. This is not safe as connection names may be different on the replica.

    See Also

    • Multi-master ring replication.

    • Using multi-source with global transaction id.

    • The work in MariaDB is based on the project description at MDEV-253.

    • The original code base comes from Taobao, developed by Peng Lixun. A big thanks to them for this important feature!

    This page is licensed: CC BY-SA / Gnu FDL

    MDEV-18777
    multi_source_replication_small

    Semisynchronous Replication

    Enhance data consistency with semisynchronous replication. Ensure that the primary waits for at least one replica to acknowledge receipt of a transaction before committing.

    Description

    is asynchronous, but MariaDB also provides a semisynchronous replication option. The feature is built into the server and is always available. In versions prior to , it was a separate plugin that needed to be installed.

    With regular asynchronous replication, replicas request events from the primary's binary log whenever the replicas are ready. The primary does not wait for a replica to confirm that an event has been received.

    With fully synchronous replication, all replicas are required to respond that they have received the events. See .

    Semisynchronous replication waits for just one replica to acknowledge that it has received and logged the events.

    set @@default_master_connection='';
    show status like 'Slave_running';
    set @@default_master_connection='other_connection';
    show status like 'Slave_running';
    mysqld --main_connection.replicate_do_db=main_database --replicate_do_db=other_database

    Semisynchronous replication therefore comes with some negative performance impact, but increased data integrity. Since the delay is based on the roundtrip time to the replica and back, this delay is minimized for servers in close proximity over fast networks.

    Semisynchronous replication is built into the server. See MDEV-13073 for more information.

    Enabling Semisynchronous Replication

    Semisynchronous replication can be enabled by setting the relevant system variables on the primary and the replica.

    If a server needs to be able to switch between acting as a primary and a replica, then you can enable both the primary and replica system variables on the server. For example, you might need to do this if MariaDB MaxScale is being used to enable auto-failover or switchover with MariaDB Monitor.

    Enabling Semisynchronous Replication on the Primary

    Semisynchronous replication can be enabled on the primary by setting the rpl_semi_sync_master_enabled system variable to ON. It can be set dynamically with SET GLOBAL. For example:

    It can also be set in a server option group in an option file prior to starting up the server. For example:

    Enabling Semisynchronous Replication on the Replica

    Semisynchronous replication can be enabled on the replica by setting the rpl_semi_sync_slave_enabled system variable to ON. It can be set dynamically with SET GLOBAL. For example:

    It can also be set in a server option group in an option file prior to starting up the server. For example:

    When switching between semisynchronous replication and asynchronous replication on a replica with replica IO threads already running, the replica I/O thread will need to be restarted. For example:

    If this is not done, then the replica IO thread will continue to use the previous setting.

    Configuring the Primary Timeout

    In semisynchronous replication, only after the events have been written to the relay log and flushed does the replica acknowledge receipt of a transaction's events. If the replica does not acknowledge the transaction before a certain amount of time has passed, then a timeout occurs and the primary switches to asynchronous replication. This will be reflected in the primary's error log with messages like the following:

    When this occurs, the Rpl_semi_sync_master_status status variable will be switched to OFF.

    When at least one semisynchronous replica catches up, semisynchronous replication is resumed. This will be reflected in the primary's error log with messages like the following:

    When this occurs, the Rpl_semi_sync_master_status status variable will be switched to ON.

    The number of times that semisynchronous replication has been switched off can be checked by looking at the value of the Rpl_semi_sync_master_no_times status variable.

    If you see a lot of timeouts like this in your environment, then you may want to change the timeout period. The timeout period can be changed by setting the rpl_semi_sync_master_timeout system variable. It can be set dynamically with SET GLOBAL. For example:

    It can also be set in a server option group in an option file prior to starting up the server. For example:

    To determine a good value for the rpl_semi_sync_master_timeout system variable, you may want to look at the values of the Rpl_semi_sync_master_net_avg_wait_time and Rpl_semi_sync_master_tx_avg_wait_time status variables.

    Configuring the Primary Wait Point

    In semisynchronous replication, there are two potential points at which the primary can wait for the replica acknowledge the receipt of a transaction's events. These two wait points have different advantages and disadvantages.

    The wait point is configured by the rpl_semi_sync_master_wait_point system variable. The supported values are:

    • AFTER_SYNC

    • AFTER_COMMIT

    It can be set dynamically with SET GLOBAL. For example:

    It can also be set in a server option group in an option file prior to starting up the server. For example:

    When this variable is set to AFTER_SYNC, the primary performs the following steps:

    1. Prepares the transaction in the storage engine.

    2. Syncs the transaction to the binary log.

    3. Waits for acknowledgement from the replica.

    4. Commits the transaction to the storage engine.

    5. Returns an acknowledgement to the client.

    The effects of the AFTER_SYNC wait point are:

    • All clients see the same data on the primary at the same time; after acknowledgement by the replica and after being committed to the storage engine on the primary.

    • If the primary crashes, then failover should be lossless, because all transactions committed on the primary would have been replicated to the replica.

    • However, if the primary crashes, then its binary log may also contain events for transactions that were prepared by the storage engine and written to the binary log, but that were never actually committed by the storage engine. As part of the server's automatic crash recovery process, the server may recover these prepared transactions when the server is restarted. This could cause the "old" crashed primary to become inconsistent with its former replicas when they have been reconfigured to replace the old primary with a new one. The old primary in such a scenario can be re-introduced only as a semisync replica. The server post-crash recovery of the server configured with rpl_semi_sync_slave_enabled = ON ensures through that the server will not have extra transactions. The reconfigured as semisync replica server's binlog gets truncated to discard transactions proven not to be committed, in any of their branches if they are multi-engine. Truncation does not occur though when there exists a non-transactional group of events beyond the truncation position in which case recovery reports an error. When the semisync replica recovery can't be carried out, the crashed primary may need to be rebuilt.

    When this variable is set to AFTER_COMMIT, the primary performs the following steps:

    1. Prepares the transaction in the storage engine.

    2. Syncs the transaction to the binary log.

    3. Commits the transaction to the storage engine.

    4. Waits for acknowledgement from the replica.

    5. Returns an acknowledgement to the client.

    The effects of the AFTER_COMMIT wait point are:

    • Other clients may see the committed transaction before the committing client.

    • If the primary crashes, then failover may involve some data loss, because the primary may have committed transactions that had not yet been acknowledged by the replicas.

    Versions

    Version
    Status
    Introduced

    N/A

    N/A

    (feature is built-in, no longer available as a separate plugin)

    1.0

    Stable

    1.0

    Gamma

    1.0

    Unknown

    System Variables

    rpl_semi_sync_master_enabled

    • Description: Set to ON to enable semi-synchronous replication primary. Disabled by default.

    • Command line: --rpl-semi-sync-master-enabled[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: boolean

    • Default Value: OFF

    rpl_semi_sync_master_timeout

    • Description: The timeout value, in milliseconds, for semi-synchronous replication in the primary. If this timeout is exceeded in waiting on a commit for acknowledgement from a replica, the primary will revert to asynchronous replication.

      • When a timeout occurs, the Rpl_semi_sync_master_status status variable will also be switched to OFF.

      • See Configuring the Primary Timeout for more information.

    • Command line: --rpl-semi-sync-master-timeout[=#]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: numeric

    • Default Value: 10000 (10 seconds)

    • Range: 0 to 18446744073709551615

    rpl_semi_sync_master_trace_level

    • Description: The tracing level for semi-sync replication. Four levels are defined:

      • 1: General level, including for example time function failures.

      • 16: More detailed level, with more verbose information.

      • 32: Net wait level, including more information about network waits.

      • 64: Function level, including information about function entries and exits.

    • Command line: --rpl-semi-sync-master-trace-level[=#]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: numeric

    • Default Value: 32

    • Range: 0 to 18446744073709551615

    rpl_semi_sync_master_wait_no_slave

    • Description: If all replicas have disconnected from the primary (i.e. Rpl_semi_sync_master_clients is 0), this variable controls whether or not the primary will still suspend the next transaction's (and any others that commit within Rpl_semi_sync_master_timeout duration) commit phase to wait for a replica to connect or reconnect, and send an ACK. If set to ON, the default, the replica count may drop to zero, and the primary will still wait for the timeout period for the next transaction, and any more that commit after this transaction within the semi-sync timeout duration. If no ACK is received in this time, the primary will revert to asynchronous replication. If set to OFF, the primary will revert to asynchronous replication as soon as the replica count drops to zero.

    • Command line: --rpl-semi-sync-master-wait-no-slave[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: boolean

    • Default Value: ON

    rpl_semi_sync_master_wait_point

    • Description: Whether the transaction should wait for semi-sync acknowledgement after having synced the binlog (AFTER_SYNC), or after having committed in storage engine (AFTER_COMMIT, the default).

      • When this variable is set to AFTER_SYNC, the primary performs the following steps:

        1. Prepares the transaction in the storage engine.

        2. Syncs the transaction to the .

        3. Waits for acknowledgement from the replica.

        4. Commits the transaction to the storage engine.

        5. Returns an acknowledgement to the client.

      • When this variable is set to AFTER_COMMIT, the primary performs the following steps:

        1. Prepares the transaction in the storage engine.

        2. Syncs the transaction to the .

        3. Commits the transaction to the storage engine.

      • In and before, this system variable does not exist. However, in those versions, the primary waits for the acknowledgement from replicas at a point that is equivalent to AFTER_COMMIT.

      • See for more information.

    • Command line: --rpl-semi-sync-master-wait-point=value

    • Scope: Global

    • Dynamic: Yes

    • Data Type: enum

    • Default Value: AFTER_COMMIT

    • Valid Values: AFTER_SYNC, AFTER_COMMIT

    rpl_semi_sync_slave_delay_master

    • Description: Only write primary info file when ack is needed.

    • Command line: --rpl-semi-sync-slave-delay-master[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: boolean

    • Default Value: OFF

    rpl_semi_sync_slave_enabled

    • Description: Set to ON to enable semi-synchronous replication replica. Disabled by default.

    • Command line: --rpl-semi-sync-slave-enabled[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: boolean

    • Default Value: OFF

    rpl_semi_sync_slave_kill_conn_timeout

    • Description: Timeout for the mysql connection used to kill the replica io_thread's connection on primary. This timeout comes into play when stop slave is executed.

    • Command line: --rpl-semi-sync-slave-kill-conn-timeout[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: numeric

    • Default Value: 5

    • Range: 0 to 4294967295

    rpl_semi_sync_slave_trace_level

    • Description: The tracing level for semi-sync replication. The levels are the same as for rpl_semi_sync_master_trace_level.

    • Command line: --rpl-semi-sync-slave-trace_level[=#]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: numeric

    • Default Value: 32

    • Range: 0 to 18446744073709551615

    Options

    init-rpl-role

    • From , , , , and , changes the condition for semi-sync recovery to truncate the binlog to instead use this option, when set to SLAVE. This avoids a possible error state where the replica’s state is ahead of the primaries. See -init-rpl-role.

    rpl-semi-sync_master

    • Description: Controls how the server should treat the plugin when the server starts up.

      • Valid values are:

        • OFF - Disables the plugin without removing it from the mysql.plugins table.

        • ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.

        • FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.

        • FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.

      • See for more information.

    • Command line: --rpl-semi-sync-master=value

    • Data Type: enumerated

    • Default Value: ON

    • Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT

    • Removed:

    rpl-semi-sync_slave

    • Description: Controls how the server should treat the plugin when the server starts up.

      • Valid values are:

        • OFF - Disables the plugin without removing it from the mysql.plugins table.

        • ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.

        • FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.

        • FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.

      • See for more information.

    • Command line: --rpl-semi-sync-slave=value

    • Data Type: enumerated

    • Default Value: ON

    • Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT

    • Removed:

    Status Variables

    For a list of status variables added when the plugin is installed, see Semisynchronous Replication Plugin Status Variables.

    This page is licensed: CC BY-SA / Gnu FDL

    Standard MariaDB replication
    Galera Cluster

    Variable

    replicate_ignore_table

    Tells the replica thread not to replicate any statement that updates the specified table, even if any other tables might be updated by the same statement.

    Variable

    replicate_rewrite_db

    Starting with , one can configure a replica to rewrite database names. It uses the format primary_database->replica_database. If a replica encounters a binary log event in which the default database (i.e., the one selected by the USE statement) is primary_database, then the replica will apply the event in replica_database instead.

    Variable

    replicate_wild_do_table

    Tells the replica thread to restrict replication to statements where any of the updated tables match the specified database and table name patterns.

    Variable

    replicate_wild_ignore_table

    Tells the replica thread not to replicate to the tables that match the given wildcard pattern.

    Status

    Slave_heartbeat_period

    How often to request a heartbeat packet from the primary (in seconds).

    Status

    Slave_received_heartbeats

    How many heartbeats do we have from the primary.

    Status

    Slave_running

    Shows if the replica is running. YES means that the sql thread and the IO thread are active. No means either one is not running. '' means that @@default_master_connection doesn't exist.

    Variable

    Sql_slave_skip_counter

    How many entries in the replication log that should be skipped (mainly used in case of errors in the log).

    Slave_heartbeat_period

    How often to request a heartbeat packet from the primary (in seconds).

    SHOW RELAYLOG ['connection_name'] EVENTS
    SHOW SLAVE ['connection_name'] STATUS
    SHOW ALL SLAVES STATUS
    [START SLAVE ['connection_name']]
    START ALL SLAVES ...
    STOP SLAVE ['connection_name'] ...
    STOP ALL SLAVES ...
    SHOW ALL SLAVES STATUS
    RESET SLAVE
    innodb-recovery-update-relay-log
    slave_net_timeout
    Slave_heartbeat_period
    Slave_retried_transactions
    Com_start_slave
    Com_stop_slave
    max_relay_log_size
    replicate_do_db
    replicate_do_table
    replicate_ignore_db
    Com_start_all_slaves
    Com_start_slave
    Com_stop_slave
    Com_stop_all_slaves
    SET GLOBAL rpl_semi_sync_master_enabled=ON;
    [mariadb]
    ...
    rpl_semi_sync_master_enabled=ON
    SET GLOBAL rpl_semi_sync_slave_enabled=ON;
    [mariadb]
    ...
    rpl_semi_sync_slave_enabled=ON
    STOP SLAVE IO_THREAD;
    START SLAVE IO_THREAD;
    [Warning] Timeout waiting for reply of binlog (file: mariadb-1-bin.000002, pos: 538), semi-sync up to file , position 0.
    [Note] Semi-sync replication switched OFF.
    [Note] Semi-sync replication switched ON with replica (server_id: 184137206) at (mariadb-1-bin.000002, 215076)
    SET GLOBAL rpl_semi_sync_master_timeout=20000;
    [mariadb]
    ...
    rpl_semi_sync_master_timeout=20000
    SET GLOBAL rpl_semi_sync_master_wait_point='AFTER_SYNC';
    [mariadb]
    ...
    rpl_semi_sync_master_wait_point=AFTER_SYNC

    Waits for acknowledgement from the replica.

  • Returns an acknowledgement to the client.

  • 1.0

    N/A

    MDEV-21117
    binary log
    binary log
    Configuring the Primary Wait Point
    UNINSTALL SONAME
    UNINSTALL PLUGIN
    Plugin Overview: Configuring Plugin Activation at Server Startup
    UNINSTALL SONAME
    UNINSTALL PLUGIN
    Plugin Overview: Configuring Plugin Activation at Server Startup

    Replication Filters

    Learn how to filter specific databases or tables from being replicated. This guide covers configuration options to replicate only the data you need on specific replicas.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    Replication filters allow users to configure replicas to intentionally skip certain events.

    Binary Log Filters for Replication Primaries

    MariaDB provides options that can be used on a to restrict local changes to specific databases from getting written to the , which also determines whether any replicas replicate those changes.

    Binary Log Filter Options

    The following options are available, and they are evaluated in the order that they are listed below. If there are conflicting settings, binlog_do_db prevails. Before , they are only available as options; from they are also available as system variables.

    binlog_do_db

    The option allows you to configure a to write statements and transactions affecting databases that match a specified name into its . Since the filtered statements or transactions will not be present in the , its replicas will not be able to replicate them.

    This option will not work with cross-database updates with . See the section for more information.

    This option cannot be set dynamically.

    When setting it on the command-line or in a server in an , the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times. For example:

    This will tell the primary to do the following:

    • Write statements and transactions affecting the database named db1 into the .

    • Write statements and transactions affecting the database named db2 into the .

    • Don't write statements and transactions affecting any other databases into the .

    binlog_ignore_db

    The option allows you to configure a to not write statements and transactions affecting databases that match a specified name into its . Since the filtered statements or transactions will not be present in the , its replicas will not be able to replicate them.

    This option will not work with cross-database updates with . See the section for more information.

    This option cannot be set dynamically.

    When setting it on the command-line or in a server in an , the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times. For example:

    This will tell the primary to do the following:

    • Don't write statements and transactions affecting the database named db1 into the .

    • Don't write statements and transactions affecting the database named db2 into the .

    • Write statements and transactions affecting any other databases into the .

    The option is effectively ignored if the option is set, so those two options should not be set together.

    Replication Filters for Replicas

    MariaDB provides options and system variables that can be used on used on a to filter events replicated in the .

    Replication Filter Options

    The following options and system variables are available, and they are evaluated in the order that they are listed below. If there are conflicting settings, the respective replicate_do_ prevails.

    replicate_rewrite_db

    The option (and, from , system variable), allows you to configure a to rewrite database names. It uses the format primary_database->replica_database. If a replica encounters a event in which the default database (i.e. the one selected by the statement) is primary_database, then the replica will apply the event in replica_database instead.

    This option will not work with cross-database updates with . See the section for more information.

    This option only affects statements that involve tables. This option does not affect statements involving the database itself, such as , , and .

    This option's rewrites are evaluated before any other replication filters configured by the replicate_* system variables.

    Statements that use table names qualified with database names do not work with other replication filters such as .

    Until , this option could not be set dynamically.

    When setting it on the command-line or in a server in an , the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times. For example:

    This will tell the replica to do the following:

    • If a event is encountered in which the default database was db1, then apply the event in db3 instead.

    • If a event is encountered in which the default database was db2, then apply the event in db4 instead.

    See for how to configure this system variable with .

    replicate_do_db

    The system variable allows you to configure a to apply statements and transactions affecting databases that match a specified name.

    This system variable will not work with cross-database updates with or when using and the statement is logged statement based. For statement-based replication, only the default database (that is, the one selected by USE) is considered, not any explicitly mentioned tables in the query. See the section for more information.

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database names that contain commas. If you need to specify database names that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Replicate statements and transactions affecting the database named db1.

    • Replicate statements and transactions affecting the database named db2.

    • Ignore statements and transactions affecting any other databases.

    See for how to configure this system variable with .

    replicate_ignore_db

    The system variable allows you to configure a to ignore statements and transactions affecting databases that match a specified name.

    This system variable will not work with cross-database updates with or when using and the statement is logged statement based. For statement-based replication, only the default database (that is, the one selected by USE) is considered, not any explicitly mentioned tables in the query. See the section for more information.

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database names that contain commas. If you need to specify names or patterns that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Ignore statements and transactions affecting databases named db1.

    • Ignore statements and transactions affecting databases named db2.

    • Replicate statements and transactions affecting any other databases.

    The system variable is effectively ignored if the system variable is set, so those two system variables should not be set together.

    See for how to configure this system variable with .

    replicate_do_table

    The system variable allows you to configure a to apply statements and transactions that affect tables that match a specified name. The table name is specified in the format: dbname.tablename.

    This system variable will not work with cross-database updates with . See the section for more information.

    This option only affects statements that involve tables. This option does not affect statements involving the database itself, such as , , and .

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database or table names or patterns that contain commas. If you need to specify database or table names that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Replicate statements and transactions affecting tables in databases named db1 and which are named tab.

    • Replicate statements and transactions affecting tables in databases named db2 and which are named tab.

    • Ignore statements and transactions affecting any other tables.

    See for how to configure this system variable with .

    replicate_ignore_table

    The system variable allows you to configure a to ignore statements and transactions that affect tables that match a specified name. The table name is specified in the format: dbname.tablename.

    This system variable will not work with cross-database updates with . See the section for more information.

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database or table names that contain commas. If you need to specify database or table names that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Ignore statements and transactions affecting tables in databases named db1 and which are named tab.

    • Ignore statements and transactions affecting tables in databases named db2 and which are named tab.

    • Replicate statements and transactions affecting any other tables.

    The system variable is effectively ignored if either the system variable or the system variable is set, so the system variable should not be used with those two system variables.

    See for how to configure this system variable with .

    replicate_wild_do_table

    The system variable allows you to configure a to apply statements and transactions that affect tables that match a specified wildcard pattern.

    The wildcard pattern uses the same semantics as the operator. This means that the following characters have a special meaning:

    • _ - The _ character matches any single character.

    • % - The % character matches zero or more characters.

    • \ - The \

    This system variable will work with cross-database updates with . See the section for more information.

    The system variable does filter databases, tables, and .

    The system variable does not filter , , and . The system variable will need to be used to filter those.

    If the table name pattern for a filter is just specified as %, then all tables in the database will be matched. In this case, the filter will also affect certain database-level statements, such as , and .

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database or table names or patterns that contain commas. If you need to specify database or table names or patterns that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Replicate statements and transactions affecting tables in databases that start with db and whose table names start with tab.

    • Replicate statements and transactions affecting the database named app1.

    • Ignore statements and transactions affecting any other tables and databases.

    See for how to configure this system variable with .

    replicate_wild_ignore_table

    The system variable allows you to configure a to ignore statements and transactions that affect tables that match a specified wildcard pattern.

    The wildcard pattern uses the same semantics as the operator. This means that the following characters have a special meaning:

    • _ - The _ character matches any single character.

    • % - The % character matches zero or more characters.

    • \ - The \

    This system variable will work with cross-database updates with . See the section for more information.

    The system variable does filter databases, tables, and .

    The system variable does not filter , , and . The system variable will need to be used to filter those.

    If the table name pattern for a filter is just specified as %, then all tables in the database will be matched. In this case, the filter will also affect certain database-level statements, such as , and .

    When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    When setting it dynamically, it is not possible to specify database or table names or patterns that contain commas. If you need to specify database or table names or patterns that contain commas, then you will need to specify them by either providing the command-line options or configuring them in a server in an when the server is .

    When setting it dynamically, the must be stopped. For example:

    When setting it on the command-line or in a server in an , the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times. For example:

    This will tell the replica to do the following:

    • Ignore statements and transactions affecting tables in databases that start with db and whose table names start with tab.

    • Ignore statements and transactions affecting all the tables in the database named app1.

    • Replicate statements and transactions affecting any other tables and databases.

    The system variable is effectively ignored if either the system variable or the system variable is set, so the system variable should not be used with those two system variables.

    See for how to configure this system variable with .

    Configuring Replication Filter Options with Multi-Source Replication

    How you configure replication filters with depends on whether you are configuring them dynamically or whether you are configuring them in a server in an .

    Setting Replication Filter Options Dynamically with Multi-Source Replication

    The usage of dynamic replication filters changes somewhat when is in use. By default, the variables are addressed to the default connection, so in a multi-source environment, the required connection needs to be specified. There are two ways to do this.

    Prefixing the Replication Filter Option with the Connection Name

    One way to change a replication filter for a multi-source connection is to explicitly specify the name when changing the filter. For example:

    Changing the Default Connection

    Alternatively, the default connection can be changed by setting the system variable, and then the replication filter can be changed in the usual fashion. For example:

    Setting Replication Filter Options in Option Files with Multi-Source Replication

    If you are using and if you would like to make this filter persist server restarts by adding it to a server in an , then the option file can also include the connection name that each filter would apply to. For example:

    CHANGE MASTER Options

    The statement has a few options that can be used to filter certain types of events.

    IGNORE_SERVER_IDS

    The option for CHANGE MASTER can be used to configure a to ignore events that originated from certain servers. Filtered binary log events will not get logged to the replica’s , and they will not be applied by the replica.

    DO_DOMAIN_IDS

    The option for CHANGE MASTER can be used to configure a to only apply events if the transaction's is in a specific value. Filtered events will not get logged to the replica’s , and they will not be applied by the replica.

    IGNORE_DOMAIN_IDS

    The option for CHANGE MASTER can be used to configure a to ignore events if the transaction's is in a specific value. Filtered events will not get logged to the replica’s , and they will not be applied by the replica.

    Replication Filters and Binary Log Formats

    The way that a replication filter is interpreted can depend on the .

    Statement-Based Logging

    When an event is logged in its statement-based format, many replication filters that affect a database will test the filter against the default database (i.e. the one selected by the statement). This applies to the following replication filters:

    When an event is logged in its statement-based format, many replication filters that affect a table will test the filter against the table in the default database (i.e. the one selected by the statement). This applies to the following replication filters:

    This means that cross-database updates do not work with replication filters and statement-based binary logging. For example, if were set, then the following would not replicate with statement-based binary logging:

    If you need to be able to support cross-database updates with replication filters and statement-based binary logging, then you should use the following replication filters:

    Row-Based Logging

    When an event is logged in its row-based format, many replication filters that affect a database will test the filter against the database that is actually affected by the event.

    Similarly, when an event is logged in its row-based format, many replication filters that affect a table will test the filter against the table in the database that is actually affected by the event.

    This means that cross-database updates work with replication filters and statement-based binary logging.

    Keep in mind that DDL statements are always logged to the in statement-based format, even when the system variable is set to ROW. This means that the notes mentioned in always apply to DDL.

    Replication Filters and Galera Cluster

    When using Galera cluster, replication filters should be used with caution. See for more details.

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    Parallel Replication

    Boost MariaDB Server replication performance with parallel replication. This section explains how to configure replicas to apply events concurrently, reducing lag and improving throughput.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    Some writes, replicated from the primary can be executed in parallel (simultaneously) on the replica. Note that for parallel replication to work, both the primary and replica need to be or later.

    Parallel Replication Overview

    MariaDB replication in general takes place in three parts:

    • Replication events are read from the primary by the IO thread and queued in the .

    • Replication events are fetched one at a time by the SQL thread from the relay log

    • Each event is applied on the replica to replicate all changes done on the primary.

    Before MariaDB 10, the third step was also performed by the SQL thread; this meant that only one event could execute at a time, and replication was essentially single-threaded. Since MariaDB 10, the third step can optionally be performed by a pool of separate replication worker threads, and thereby potentially increase replication performance by applying multiple events in parallel.

    How to Enable Parallel Replica

    To enable, specify in your file as an argument to mysql. Parallel replication can in addition be disabled on a per-multi-source connection by setting to "none".

    The value (#) of slave_parallel_threads specifies how many threads will be created in a pool of worker threads used to apply events in parallel for all your replicas (this includes ). If the value is zero, then no worker threads are created, and old-style replication is used where events are applied inside the SQL thread. Usually the value, if non-zero, should be at least two times the number of multi-source primary connections used. It makes little sense to use only a single worker thread for one connection; this will incur some overhead in inter-thread communication between the SQL thread and the worker thread, but with just a single worker thread event cannot be applied in parallel anyway.

    slave-parallel-threads=# is a dynamic variable that can be changed without restarting mysqld. All replicas' connections must however be stopped when changing the value.

    Configuring the Replica Parallel Mode

    Parallel replication can be in-order or out-of-order:

    • In-order executes transactions in parallel but orders the commit step of the transactions to happen in the exact same order as on the primary. Transactions are only executed in parallel to the extent that this can be automatically verified to be possible without any conflicts. This means that the use of parallelism is completely transparent to the application.

    • Out-of-order can execute and commit transactions in different order on the replica than originally on the primary. This means that the application must be tolerant to seeing updates occur in different order. The application is also responsible for ensuring that there are no conflicts between transactions that are replicated out-of-order. Out-of-order is only used in GTID mode and only when explicitly enabled by the application, using the replication domain that is part of the GTID.

    In-Order Parallel Replication

    Optimistic Mode of In-Order Parallel Replication

    Optimistic mode of in-order parallel replication provides a lot of opportunities for parallel apply on the replica while still preserving exact transaction semantics from the point of view of applications. It is the default mode from .

    Optimistic mode of in-order parallel replication can be configured by setting the system variable to optimistic on the replica.

    Any transactional DML (INSERT/UPDATE/DELETE) is allowed to run in parallel, up to the limit of . This may cause conflicts on the replica, e.g. if two transactions try to modify the same row. Any such conflict is detected, and the latter of the two transactions is rolled back, allowing the former to proceed. The latter transaction is then re-tried once the former has completed.

    The term "optimistic" is used for this mode, because the server optimistically assumes that few conflicts will occur, and that the extra work spent rolling back and retrying conflicting transactions is justified from the gain from running most transactions in parallel.

    There are a few heuristics to try to avoid needless conflicts. If a transaction executed a row lock wait on the primary, it will not be run in parallel on the replica. Transactions can also be marked explicitly as potentially conflicting on the primary, by setting the variable . More such heuristics may be added in later MariaDB versions. There is a further called "aggressive", where these heuristics are disabled, allowing even more transactions to be applied in parallel.

    Non-transactional DML and DDL is not safe to optimistically apply in parallel, as it cannot be rolled back in case of conflicts. Thus, in optimistic mode, non-transactional (such as MyISAM) updates are not applied in parallel with earlier events (it is however possible to apply a MyISAM update in parallel with a later InnoDB update). DDL statements are not applied in parallel with any other transactions, earlier or later.

    The different kind of transactions can be identified in the output of . For example:

    GTID 0-1-42 is marked as being DDL. GTID 0-1-47 is marked as being non-transactional DML, while GTID 0-1-49 is transactional DML (seen on the "trans" keyword). GTID 0-1-49 was additionally run with set on the primary. GTID 0-1-59 is transactional DML that had a row lock wait when run on the primary (the "waited" keyword).

    Aggressive Mode of In-Order Parallel Replication

    Aggressive mode of in-order parallel replication is very similar to optimistic mode. The main difference is that the replica does not consider whether transactions conflicted on the primary when deciding whether to apply the transactions in parallel.

    Aggressive mode of in-order parallel replication can be configured by setting the system variable to aggressive on the replica.

    Conservative Mode of In-Order Parallel Replication

    Conservative mode of in-order parallel replication uses the on the primary to discover potential for parallel apply of events on the replica. If two transactions commit together in a on the primary, they are written into the binlog with the same commit id. Such events are certain to not conflict with each other, and they can be scheduled by the parallel replication to run in different worker threads.

    Conservative mode of in-order parallel replication is the default mode until , but it can also be configured by setting the system variable to conservative on the replica.

    Two transactions that were committed separately on the primary can potentially conflict (eg. modify the same row of a table). Thus, the worker that applies the second transaction will not start immediately but wait until the first transaction begins the commit step; at this point it is safe to start the second transaction, as it can no longer disrupt the execution of the first one.

    Here is example output from that shows how GTID events are marked with commit id. The GTID 0-1-47 has no commit id and cannot run in parallel. The GTIDs 0-1-48 and 0-1-49 have the same commit id 630, and can thus replicate in parallel with one another on a replica:

    In either case, when the two transactions reach the point where the low-level commit happens and commit order is determined, the two commits are sequenced to happen in the same order as on the primary, so that operation is transparent to applications.

    The opportunities for parallel replication on replicas can be highly increased if more transactions are committed in a on the primary. This can be tuned using the and variables. If for example the application can tolerate up to 50 milliseconds extra delay for transactions on the primary, one can set binlog_commit_wait_usec=50000 andbinlog_commit_wait_count=20 to get up to 20 transactions at a time available for replication in parallel. Care must however be taken to not set binlog_commit_wait_usec too high, as this could cause significant slowdown for applications that run a lot of small transactions serially one after the other.

    Note that even if there is no parallelism available from the primary , there is still an opportunity for speedup from in-order parallel replication, since the actual commit steps of different transactions can run in parallel. This can be particularly effective on a replica with binlog enabled (), and more so if replica is configured to be crash-safe ( and ), as this makes possible on the replica.

    Minimal Mode of In-Order Parallel Replication

    Minimal mode of in-order parallel replication _only_allows the commit step of transactions to be applied in parallel; all other steps are applied serially.

    Minimal mode of in-order parallel replication can be configured by setting the system variable to minimal on the replica.

    Out-of-Order Parallel Replication

    Out-of-order parallel replication happens (only) when using GTID mode, when GTIDs with different replication domains are used. The replication domain is set by the DBA/application using the variable gtid_domain_id.

    Two transactions having GTIDs with different domain_id are scheduled to different worker threads by parallel replication and are allowed to execute completely independently from each other. It is the responsibility of the application to only set different domain_ids for transactions that are truly independent, and are guaranteed to not conflict with each other. The application must also be able to work correctly even though the transactions with different domain_id are seen as committing in different order between the replica and the primary, and between different replicas.

    Out-of-order parallel replication can potentially give more performance gain than in-order parallel replication, since the application can explicitly give more opportunities for running transactions in parallel than what the server can determine on its own automatically.

    One simple but effective usage is to run long-running statements, such as ALTER TABLE, in a separate replication domain. This allows replication of other transactions to proceed uninterrupted:

    Normally, a long-running ALTER TABLE or other query will stall all following transactions, causing the replica to become behind the primary as least as long time as it takes to run the long-running query. By using out-of-order parallel replication by setting the replication domain id, this can be avoided. The DBA/application must ensure that no conflicting transactions will be replicated while the ALTER TABLE runs.

    Another common opportunity for out-of-order parallel replication comes in connection with multi-source replication. Suppose we have two different primaries M1 and M2, and we are using multi-source replication to have S1 as a replica of both M1 and M2. S1 will apply events received from M1 in parallel with events received from M2. If we now have a third-level replica S2 that replicates from S1 as primary, we want S2 to also be able to apply events that originated on M1 in parallel with events that originated on M2. This can be achieved with out-of-order parallel replication, by setting gtid_domain_id different on M1 and M2.

    Note that there are no special restrictions on what operations can be replicated in parallel using out-of-order; such operations can be on the same database/schema or even on the same table. The only restriction is that the operations must not conflict, that is they must be able to be applied in any order and still end up with the same result.

    When using out-of-order parallel replication, the current replica position in the primary's binlog becomes multi-dimensional - each replication domain can have reached a different point in the primary binlog at any one time. The current position can be seen from the variablegtid_slave_pos. When the replica is stopped, restarted, or switched to replicate from a different primary using CHANGE MASTER, MariaDB automatically handles restarting each replication domain at the appropriate point in the binlog.

    Out-of-order parallel replication is disabled when (or none).

    Checking Worker Thread Status in SHOW PROCESSLIST

    The worker threads will be listed as "system user" in . Their state will show the query they are currently working on, or it can show one of these:

    • "Waiting for work from main SQL threads". This means that the worker thread is idle, no work is available for it at the moment.

    • "Waiting for prior transaction to start commit before starting next transaction". This means that the previous batch of transactions that committed together on the primary primary has to complete first. This worker thread is waiting for that to happen before it can start working on the following batch.

    • "Waiting for prior transaction to commit". This means that the transaction has been executed by the worker thread. In order to ensure in-order commit, the worker thread is waiting to commit until the previous transaction is ready to commit before it.

    Expected Performance Gain

    Here is an article showing up to ten times improvement when using parallel replication: .

    Configuring the Maximum Size of the Parallel Replica Queue

    The system variable can be used to configure the maximum size of the parallel replica queue. This system variable is only meaningful when parallel replication is configured (i.e. when > 0).

    When parallel replication is used, the will read ahead in the relay logs, queueing events in memory while looking for opportunities for executing events in parallel. The system variable sets a limit for how much memory it will use for this.

    The configured value of the system variable is actually allocated for each , so the total allocation is actually equivalent to the following:

    *

    If this value is set too high, and the replica is far (eg. gigabytes of binlog) behind the primary, then the can quickly read all of that and fill up memory with huge amounts of binlog events faster than the can consume them.

    On the other hand, if set too low, the might not have sufficient space for queuing enough events to keep the worker threads busy, which could reduce performance. In this case, the will have the that states Waiting for room in worker thread event queue. For example:

    The system variable does not define a hard limit, since the events that are currently executing always need to be held in-memory. This means that at least two events per can always be queued in-memory, regardless of the value of .

    Usually, the system variable should be set large enough that the is able to read far enough ahead in the to exploit all possible parallelism. In normal operation, the replica will hopefully not be too far behind, so there will not be a need to queue much data in-memory. The system variable could be set fairly high (e.g. a few hundred kilobytes) to not limit throughput. It should just be set low enough that total allocation of the parallel replica queue will not cause the server to run out of memory.

    Configuration Variable slave_domain_parallel_threads

    The pool of replication worker threads is shared among all multi-source primary connections, and among all replication domains that can replicate in parallel using out-of-order.

    If one primary connection or replication domain is currently processing a long-running query, it is possible that it will allocate all the worker threads in the pool, only to have them wait for the long-running query to complete, stalling any other primary connection or replication domain, which will have to wait for a worker thread to become free.

    This can be avoided by setting to a number that is lower than slave_parallel_threads. When set different from zero, each replication domain in one primary connection can reserve at most that many worker threads at any one time, leaving the rest (up to the value of ) free for other primary connections or replication domains to use in parallel.

    The slave_domain_parallel_threads variable is dynamic and can be changed without restarting the server; all replicas must be stopped while changing it, though.

    Implementation Details

    The implementation is described in .

    See Also

    • (MariaDB.com blog)

    • (MariaDB.com blog)

    This page is licensed: CC BY-SA / Gnu FDL

    character is used to escape the other special characters in cases where you need the literal character.
    character is used to escape the other special characters in cases where you need the literal character.
    replicate_ignore_db
    replication primary
    binary log
    binlog_do_db
    replication primary
    binary log
    binary log
    statement-based logging
    Statement-Based Logging
    option group
    option file
    binary log
    binary log
    binary log
    binlog_ignore_db
    replication primary
    binary log
    binary log
    statement-based logging
    Statement-Based Logging
    option group
    option file
    binary log
    binary log
    binary log
    binlog_ignore_db
    binlog_do_db
    replica
    binary log
    replicate_rewrite_db
    replica
    binary log
    USE
    statement-based logging
    Statement-Based Logging
    CREATE DATABASE
    ALTER DATABASE
    DROP DATABASE
    replicate_do_table
    option group
    option file
    binary log
    binary log
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_do_db
    replica
    statement-based logging
    mixed-based logging
    Statement-Based Logging
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_ignore_db
    replica
    statement-based logging
    mixed-based logging
    Statement-Based Logging
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    replicate_ignore_db
    replicate_do_db
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_do_table
    replica
    statement-based logging
    Statement-Based Logging
    CREATE DATABASE
    ALTER DATABASE
    DROP DATABASE
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_ignore_table
    replica
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    replicate_ignore_table
    replicate_do_table
    replicate_wild_do_table
    replicate_ignore_table
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_wild_do_table
    replica
    LIKE
    statement-based logging
    Statement-Based Logging
    views
    triggers
    stored procedures
    stored functions
    events
    replicate_do_db
    CREATE DATABASE
    ALTER DATABASE
    DROP DATABASE
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    replicate_wild_ignore_table
    replica
    LIKE
    statement-based logging
    Statement-Based Logging
    views
    triggers
    stored procedures
    stored functions
    events
    replicate_ignore_db
    CREATE DATABASE
    ALTER DATABASE
    DROP DATABASE
    SET GLOBAL
    option group
    option file
    started
    replica threads
    option group
    option file
    replicate_ignore_table
    replicate_do_table
    replicate_wild_do_table
    replicate_ignore_table
    Configuring Replication Filter Options with Multi-Source Replication
    multi-source replication
    multi-source replication
    option group
    option file
    multi-source replication
    default_master_connection
    multi-source replication
    option group
    option file
    CHANGE MASTER
    binary log
    IGNORE_SERVER_IDS
    replica
    binary log
    relay log
    DO_DOMAIN_IDS
    replica
    binary log
    GTID
    gtid_domain_id
    binary log
    relay log
    IGNORE_DOMAIN_IDS
    replica
    binary log
    GTID
    gtid_domain_id
    binary log
    relay log
    binary log format
    USE
    binlog_do_db
    binlog_ignore_db
    replicate_rewrite_db
    replicate_do_db
    USE
    replicate_do_table
    replicate_ignore_table
    replicate_do_table=db2.tab
    replicate_wild_do_table
    replicate_wild_ignore_table
    binary log
    binlog_format
    Statement-Based Logging
    Dynamic replication filters — our wheel will be square!
    Configuring MariaDB Galera Cluster: Replication Filters
    relay log
    slave-parallel-threads=#
    my.cnf
    @@connection_name.slave-parallel-mode
    multi-source replication
    slave_parallel_mode
    @@slave_domain_parallel_threads
    @@skip_parallel_replication
    --slave-parallel-mode
    mariadb-binlog
    @@skip_parallel_replication
    slave_parallel_mode
    group commit
    group commit
    slave_parallel_mode
    mariadb-binlog
    group commit
    binlog_commit_wait_count
    binlog_commit_wait_usec
    group commit
    log_slave_updates=1
    sync_binlog=1
    innodb_flush_log_at_trx_commit=1
    group commit
    slave_parallel_mode
    --slave-parallel-mode=minimal
    SHOW PROCESSLIST
    18435.html
    slave_parallel_max_queued
    slave_parallel_threads
    SQL thread
    slave_parallel_max_queued
    slave_parallel_max_queued
    worker thread
    slave_parallel_max_queued
    slave_parallel_threads
    SQL thread
    worker threads
    SQL thread
    SQL thread
    thread state
    slave_parallel_max_queued
    binary log
    worker thread
    slave_parallel_threads
    slave_parallel_threads
    SQL thread
    binary log
    slave_parallel_max_queued
    slave_domain_parallel_threads
    slave_parallel_threads
    MDEV-4506
    Better Parallel Replication for MariaDB and MySQL
    Evaluating MariaDB & MySQL Parallel Replication Part 2: Slave Group Commit
    [mariadb]
    ...
    binlog_do_db=db1
    binlog_do_db=db2
    [mariadb]
    ...
    binlog_ignore_db=db1
    binlog_ignore_db=db2
    [mariadb]
    ...
    replicate_rewrite_db=db1->db3
    replicate_rewrite_db=db2->db4
    STOP SLAVE;
    SET GLOBAL replicate_do_db='db1,db2';
    START SLAVE;
    [mariadb]
    ...
    replicate_do_db=db1
    replicate_do_db=db2
    STOP SLAVE;
    SET GLOBAL replicate_ignore_db='db1,db2';
    START SLAVE;
    [mariadb]
    ...
    replicate_ignore_db=db1
    replicate_ignore_db=db2
    STOP SLAVE;
    SET GLOBAL replicate_do_table='db1.tab,db2.tab';
    START SLAVE;
    [mariadb]
    ...
    replicate_do_table=db1.tab
    replicate_do_table=db2.tab
    STOP SLAVE;
    SET GLOBAL replicate_ignore_table='db1.tab,db2.tab';
    START SLAVE;
    [mariadb]
    ...
    replicate_ignore_table=db1.tab
    replicate_ignore_table=db2.tab
    STOP SLAVE;
    SET GLOBAL replicate_wild_do_table='db%.tab%,app1.%';
    START SLAVE;
    [mariadb]
    ...
    replicate_wild_do_table=db%.tab%
    replicate_wild_do_table=app1.%
    STOP SLAVE;
    SET GLOBAL replicate_wild_ignore_table='db%.tab%,app1.%';
    START SLAVE;
    [mariadb]
    ...
    replicate_wild_ignore_table=db%.tab%
    replicate_wild_ignore_table=app1.%
    STOP SLAVE 'gandalf';
    SET GLOBAL gandalf.replicate_do_table='database1.table1,database1.table2,database1.table3';
    START SLAVE 'gandalf';
    SET default_master_connection = 'gandalf';
    STOP SLAVE; 
    SET GLOBAL replicate_do_table='database1.table1,database1.table2,database1.table3';
    START SLAVE;
    [mariadb]
    ...
    gandalf.replicate_do_db=database1
    saruman.replicate_do_db=database2
    USE db1;
    INSERT INTO db2.tab VALUES (1);
    #150324 13:06:26 server id 1  end_log_pos 6881 	GTID 0-1-42 ddl
    ...
    #150324 13:06:26 server id 1  end_log_pos 7816 	GTID 0-1-47
    ...
    #150324 13:06:26 server id 1  end_log_pos 8177  GTID 0-1-49 trans
    /*!100101 SET @@session.skip_parallel_replication=1*//*!*/;
    ...
    #150324 13:06:26 server id 1  end_log_pos 9836 	GTID 0-1-59 trans waited
    #150324 12:54:24 server id 1  end_log_pos 20052 	GTID 0-1-47 trans
    ...
    #150324 12:54:24 server id 1  end_log_pos 20212 	GTID 0-1-48 cid=630 trans
    ...
    #150324 12:54:24 server id 1  end_log_pos 20372 	GTID 0-1-49 cid=630 trans
    SET SESSION gtid_domain_id=1
    ALTER TABLE t ADD INDEX myidx(b)
    SET SESSION gtid_domain_id=0
    +----+-------------+-----------+------+---------+--------+-----------------------------------------------+------------------+----------+
    | Id | User        | Host      | db   | Command | Time   | State                                         | Info             | Progress |
    +----+-------------+-----------+------+---------+--------+-----------------------------------------------+------------------+----------+
    |  3 | system user |           | NULL | Connect |    139 | closing tables                                | NULL             |    0.000 |
    |  4 | system user |           | NULL | Connect |    139 | Waiting for work from SQL thread              | NULL             |    0.000 |
    |  6 | system user |           | NULL | Connect | 264274 | Waiting for master to send event              | NULL             |    0.000 |
    | 10 | root        | localhost | NULL | Sleep   |     43 |                                               | NULL             |    0.000 |
    | 21 | system user |           | NULL | Connect |     45 | Waiting for room in worker thread event queue | NULL             |    0.000 |
    | 54 | root        | localhost | NULL | Query   |      0 | init                                          | SHOW PROCESSLIST |    0.000 |
    +----+-------------+-----------+------+---------+--------+-----------------------------------------------+------------------+----------+

    Global Transaction ID

    Understand how Global Transaction IDs (GTIDs) track replication events. Learn to use GTIDs for simplified failover, easier topology changes, and crash-safe replication.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    Note that MariaDB and MySQL have different GTID implementations, and that these are not compatible with each other. MariaDB can be a replica for a MySQL primary but MySQL cannot be a replica for a MariaDB primary.

    Overview

    MariaDB replication in general works as follows (see for more information):

    On a master server, all updates to the database (DML and DDL) are written into the as binlog events. A replica server connects to the primary and reads the binlog events, then applies the events locally to replicate the same changes as done on the primary. A server can be both a primary and a replica at the same time, and it is thus possible for binlog events to be replicated through multiple levels of servers.

    A replica server keeps track of the position in the primary's binlog of the last event applied on the replica. This allows the replica server to re-connect and resume from where it left off after replication has been temporarily stopped. It also allows a replica to disconnect, be cloned and then have the new replica resume replication from the same primary.

    Global transaction ID (GTID) introduces a new event attached to each event group in the binlog. An event group is a collection of events that are always applied as a unit. They are best thought of as a "transaction", though they also include non-transactional DML statements, as well as DDL. When an event group is replicated from primary server to replica server, the global transaction ID is preserved. The GTID is globally unique across an entire group of servers, making it easy to uniquely identify the same binlog events on different servers that replicate each other. GTIDs are generated for all event groups, independent of (i.e. ROW, STATEMENT, andMIXED formats are all supported).

    Benefits

    Using global transaction ID provides two main benefits:

    1. Easy to change a replica server to connect to and replicate from a different primary server.

    The replica remembers the global transaction ID of the last event group applied from the old primary. This makes it easy to know where to resume replication on the new primary, since the global transaction IDs are known throughout the entire replication hierarchy. This is not the case when using old-style replication; in this case the replica knows only the specific file name and offset of the old primary server of the last event applied. There is no simple way to guess from this the correct file name and offset on a new primary.

    1. The state of the replica is recorded in a crash-safe way.

    The replica keeps track of its current position (the global transaction ID of the last transaction applied) in the system table. If this table is using a transactional storage engine (such as InnoDB, which is the default), then updates to the state are done in the same transaction as the updates to the data. This makes the state crash-safe; if the replica server crashes, crash recovery on restart will make sure that the recorded replication position matches the changes that were actually replicated. This is not the case for old-style replication, where the state is recorded in a file relay-log.info, which is updated independently of the actual data changes and can easily get out of sync if the replica server crashes. (This works for DML to transactional tables; non-transactional tables and DDL in general are not crash-safe in MariaDB.)

    Because of these two benefits, it is generally recommended to use global transaction ID for any replication setups based on or later. However, old-style replication continues to work as always, so there is no pressing need to change existing setups. Global transaction ID integrates smoothly with old-style replication, and the two can be used freely together in the same replication hierarchy. There is no special configuration needed of the server to start using global transaction ID. However, it must be explicitly set for a replica server with the appropriate option; by default old-style replication is used by a replication replica, to maintain backwards compatibility.

    Implementation

    A global transaction ID, or GTID for short, consists of three numbers separated with dashes '-'. For example:

    0-1-10

    • The first number 0 is the domain ID, which is specific for global transaction ID (more on this below). It is a 32-bit unsigned integer.

    • The second number is the server ID, the same as is also used in old-style replication. It is a 32-bit unsigned integer.

    • The third number is the sequence number. This is a 64-bit unsigned integer that is monotonically increasing for each new event group logged into the binlog.

    The server ID is set to the server ID of the server where the event group is first logged into the binlog. The sequence number is increased on a server for every event group logged. Since server IDs must be unique for every server, this makes the (server_id, sequence_number) pair, and hence the whole GTID, globally unique.

    Using a 64-bit number provides ample range that there should be no risk of it overflowing in the foreseeable future. However, one should not artificially (by setting gtid_seq_no) inject a GTID with a very high sequence number close to the limit of 64-bit.

    The Domain ID

    When events are replicated from a primary server to a replica server, the events are always logged into the replica's binlog in the same order that they were read from the primary's binlog. Thus, if there is only ever a single primary server receiving (non-replication) updates at a time, then the binlog order will be identical on every server in the replication hierarchy.

    This consistent binlog order is used by the replica to keep track of its current position in the replication. Basically, the replica remembers the GTID of the last event group replicated from the primary. When reconnecting to a primary, whether the same one or a new one, it sends this GTID position to the primary, and the primary starts sending events from the first event after the corresponding event group.

    However, if user updates are done independently on multiple servers at the same time, then in general it is not possible for binlog order to be identical across all servers. This can happen when using multi-source replication, with multi-primary ring topologies, or just if manual updates are done on a replica that is replicating from active primary. If the binlog order is different on the new primary from the order on the old primary, then it is not sufficient for the replica to keep track of a single GTID to completely record the current state.

    The domain ID, the first component of the GTID, is used to handle this.

    In general, the binlog is not a single ordered stream. Rather, it consists of a number of different streams, each one identified by its own domain ID. Within each stream, GTIDs always have the same order in every server binlog. However, different streams can be interleaved in different ways on different servers.

    A replica server then keeps track of its replication position by recording the last GTID applied within each replication stream. When connecting to a new primary, the replica can start replication from a different point in the binlog for each domain ID.

    For more details on using multi-primary setups and multiple domain IDs, see .

    Simple replication setups only have a single primary being updated by the application at any one time. In such setups, there is only a single replication stream needed. Then domain ID can be ignored, and left as the default of 0 on all servers.

    Using Global Transaction IDs

    Global transaction ID is enabled automatically. Each event group logged to the binlog receives a GTID event, as can be seen with or .

    The replica automatically keeps track of the GTID of the last applied event group, as can be seen from the variable:

    When a replica connects to a primary, it can use either global transaction ID or old-style filename/offset to decide where in the primary binlogs to start replicating from. To use global transaction ID, use the master_use_gtid option:

    CHANGE MASTER TO master_use_gtid = { slave_pos | current_pos | no }

    A replica is configured to use GTID by CHANGE MASTER TO master_use_gtid=slave_pos. When the replica connects to the primary, it will start replication at the position of the last GTID replicated to the replica, which can be seen in the variable . Since GTIDs are the same across all replication servers, the replica can then be pointed to a different primary, and the correct position will be determined automatically.

    But suppose that we set up two servers A and B and let A be the primary and B the replica. It runs for a while. Then at some point we take down A, and B becomes the new primary. Then later we want to add A back, this time as a replica.

    Since A was never a replica before, it does not have any prior replicated GTIDs, and will be empty. To allow A to be added as a replica automatically,master_use_gtid=current_pos can be used. This will connect using the value of the variable instead of , which also takes into account GTIDs written into the binlog when the server was a primary.

    When using master_use_gtid=current_pos there is no need to consider whether a server was a primary or a replica prior to using . But care must be taken not to inject extra transactions into the binlog on the replica server that are not intended to be replicated to other servers. If such an extra transaction is the most recent when the replica starts, it will be used as the starting point of replication. This will probably fail because that transaction is not present on the primary. To avoid local changes on a replica server to go into the binlog, set to 0.

    If it is undesirable that changes to the binlog on the replica affects the GTID replication position, then master_use_gtid=slave_pos should be used. Then the replica will always connect to the primary at the position of the last replicated GTID. This may avoid some surprises for users that expect behavior consistent with traditional replication, where the replication position is never changed by local changes done on a server.

    When is enabled (by setting@@GLOBAL.gtid_strict_mode to 1), it is normally best to usecurrent_pos. In strict mode, extra transactions on the Replica are disallowed as they would generate a local gtid. The local gtid would contain the current seqno the Replica is at incremented by 1, at the next transaction that will come from the Primary, the Replica would find such seqno already used by its own local transaction and it will stop replicating for safety until the situation is assessed.

    If a replica is configured with the binlog disabled,current_pos and slave_pos are equivalent.

    Even when a replica is configured to connect with the old-style binlog filename and offset (CHANGE MASTER TO master_log_file=..., master_log_pos=...), it will still keep track of the current GTID position in @@GLOBAL.gtid_slave_pos. This means that an existing replica previously configured and running can be changed to connect with GTID (to the same or a new master) simply with:

    CHANGE MASTER TO master_use_gtid = slave_pos

    The replica remembers that master_use_gtid=slave_pos|master_pos was specified and will use it also for subsequent connects, until it is explicitly changed by specifyingmaster_log_file/pos=... ormaster_use_gtid=no. The current value can be seen as the field Using_Gtid of SHOW SLAVE STATUS:

    The replica server internally uses the to store the GTID position (and so preserve the value of @@GLOBAL.gtid_slave_pos across server restarts). After upgrading a server to 10.0, it is necessary to run (as always) to get the table created.

    In order to be crash-safe, this table must use a transactional storage engine such as InnoDB. When MariaDB is first installed (or upgraded to 10.0.2+) the table is created using the default storage engine - which itself defaults to InnoDB. If there is a need to change the storage engine for this table (to make it transactional on a system configured with as the default storage engine, for example), use :

    ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB

    The should not be modified in any other way. In particular, do not try to update the rows in the table to change the replica's idea of the current GTID position; instead use

    SET GLOBAL gtid_slave_pos = '0-1-1'

    Starting from , the server variable can preferably be set to make the server handle this automatically. See the description of the for details.

    Using current_pos vs. slave_pos

    When setting the replication parameter, you have the option of enabling Global Transaction IDs to use either the current_pos or slave_pos values.

    Using the value current_pos causes the replica to set its position based on the system variable, which is a union of and . Using the value slave_pos causes the replica to instead set its position based on the system variable.

    You may run into issues when you use the value current_pos if you write any local transactions on the replica. For instance, if you issue an statement or otherwise write to a table while the are stopped, then new local GTIDs may be generated in , which will affect the replica's value of . This may cause errors when the are restarted, since the local GTIDs will be absent from the primary.

    You can correct this issue by setting the replication parameter to slave_pos instead of current_pos. For example:

    Using GTIDs with Parallel Replication

    If is in use, then events that were logged with GTIDs with different values can be applied in parallel in an manner.

    Using GTIDs with MariaDB Galera Cluster

    Starting with , MariaDB Galera Cluster has limited support for GTIDs. See for more information.

    Setting up a New Replica Server with Global Transaction ID

    Setting up a new replica server with global transaction ID is not much different from setting up an old-style replica. The basic steps are:

    1. Setup the new server and load it with the initial data.

    2. Start the replica replicating from the appropriate point in the primary's binlog.

    Setting up a New Replica with an Empty Server

    The simplest way for testing purposes is probably to setup a new, empty replica server and replicate all of the primary's binlogs from the start (this is usually not feasible in a realistic production setup, as the initial binlog files will probably have been purged or take too long to apply).

    The replica server is installed in the normal way. By default, the GTID position for a newly installed server is empty, which makes the replica replicate from the start of the primary's binlogs. But if the replica was used for other purposes before, the initial position can be explicitly set to empty first:

    SET GLOBAL gtid_slave_pos = "";

    Next, point the replica to the master with . Specify master_host etc. as usual. But instead of specifying master_log_file and master_log_pos manually, use master_use_gtid=current_pos (orslave_pos to have GTID do it automatically:

    Setting up a New Replica From a Backup

    The normal way to set up a new replication replica is to take a backup from an existing server (either a primary or replica in the replication topology), and then restore that backup on the server acting as the new replica, and the configure it to start replicating from the appropriate position in the primary's binary log.

    It is important that the position at which replication is started corresponds exactly to the state of the data at the point in time that the backup was taken. Otherwise, the replica can end up with different data than the primary because of missing or duplicated transactions. Of course, if there are no writes to the server being backed up during the backup process, then a simple will give the correct position.

    See the description of the specific backup tool to determine how to get the binary log position that corresponds to the backup.

    Once the current binary log position for the backup has been obtained, in the form of a binary log file name and position, the corresponding GTID position can be obtained from on the server that was backed up:

    The new replica can then start replicating from the primary by setting the correct value for , and then executing with the relevant values for the primary, and then starting the by executing . For example:

    This method is particularly useful when setting up a new replica from a backup of the primary. Remember to ensure that the value of configured on the new replica is different from that of any other server in the replication topology.

    If the backup was taken of an existing replica server, then the new replica should already have the correct GTID position stored in the table. This is assuming that this table was backed up and that it was backed up in a consistent manner with changes to other tables. In this case, there is no need to explicitly look up the GTID position on the old server and set it on the new replica - it will be already correctly loaded from the table. This however does not work if the backup was taken from the primary - because then the current GTID position is contained in the binary log, not in the table or any other table.

    Setting up a New Replica with mariadb-backup

    A new replica can easily be set up with , which is a fork of . See for more information.

    Setting up a New Replica with mariadb-dump

    A new replica can also be set up with .

    automatically includes the GTID position as a comment in the backup file if either the or option is used. It also automatically includes the commands to set and execute in the backup file if the option is used with either the or option.

    Switching An Existing Old-Style Replica To Use GTID.

    If there is already an existing replica running using old-style binlog filename/offset position, then this can be changed to use GTID directly. This can be useful for upgrades for example, or where there are already tools to setup new replica using old-style binlog positions.

    When a replica connects to a primary using old-style binlog positions, and the primary supports GTID (i.e. is or later), then the replica automatically downloads the GTID position at connect and updates it during replication. Thus, once a replica has connected to the GTID-aware primary at least once, it can be switched to using GTID without any other actions needed;

    (A later version will probably add a way to setup the replica so that it will connect with old-style binlog file/offset the first time, and automatically switch to using GTID on subsequent connects.)

    Changing a Replica to Replicate From a Different Primary

    Once replication is running with GTID (master_use_gtid=current_pos|slave_pos), the replica can be pointed to a new primary simply by specifying in CHANGE MASTER the new master_host (and if required master_port, master_user, and master_password):

    The replica has a record of the GTID of the last applied transaction from the old primary, and since GTIDs are identical across all servers in a replication hierarchy, the replica will just continue from the appropriate point in the new primary's binlog.

    It is important to understand how this change of primary work. The binlog is an ordered stream of events (or multiple streams, one per replication domain, (see ). Events within the stream are always applied in the same order on every replica that replicates it. The MariaDB GTID relies on this ordering, so that it is sufficient to remember just a single point within the stream. Since event order is the same on every server, switching to the point of the same GTID in the binlog of another server will give the same result.

    This translates into some responsibility for the user. The MariaDB GTID replication is fully asynchronous, and fully flexible in how it can be configured. This makes it possible to use it in ways where the assumption that binlog sequence is the same on all servers is violated. In such cases, when changing primary, GTID will still attempt to continue at the point of current GTID in the new binlog.

    The most common way that binlog sequence gets different between servers is when the user/DBA does updates directly on a replica server (and these updates are written into the replica's binlog). This results in events in the replica's binlog that are not present on the primary or any other replicas. This can be avoided by setting the session variable sql_log_bin false while doing such updates, so they do not go into the binlog.

    It is normally best to avoid any differences in binlogs between servers. That being said, MariaDB replication is designed for maximum flexibility, and there can be valid reasons for introducing such differences from time to time. It this case, it just needs to be understood that the GTID position is a single point in each binlog stream (one per replication domain), and how this affects the users particular setup.

    Differences can also occur when two primary are active at the same time in a replication hierarchy. This happens when using a multi-primary ring. But it can also occur in a simple primary-replica setup, during switch to a new primary, if changes on the old primary is not allowed to fully replicate to all replica servers before switching primary. Normally, to switch primary, first writes to the old primary should be stopped, then one should wait for all changes to be replicated to the new primary, and only then should writes begin on the new primary. Deliberately using multiple active primary is also supported, this is described in the next section.

    The can be used to enforce identical binlogs across servers. When it is enabled, most actions that would cause differences are rejected with an error.

    Use With Multi-Source Replication and Other Multi-Primary Setups

    MariaDB global transaction ID supports having multiple primarys active at the same time. Typically this happens with either multi-source replication or multi-primary ring setups.

    In such setups, each active primary must be configured with its own distinct replication domain ID, . The binlog will then in effect consists of multiple independent streams, one per active primary. Within one replication domain, binlog order is always the same on every server. But two different streams can be interleaved differently in different server binlogs.

    The GTID position of a given replica is then not a single GTID. Rather, it becomes the GTID of the last event group applied for each value of domain ID, in effect the position reached in each binlog stream. When the replica connects to a primary, it can continue from one stream in a different binlog position than another stream. Since order within one stream is consistent across all servers, this is sufficient to always be able to continue replication at the correct point in any new primary server(s).

    Domain IDs are assigned by the DBA, according to the need of the application. The default value of @@GLOBAL.gtid_domain_id is 0. This is appropriate for most replication setups, where only a single primary is active at a time. The MariaDB server will never by itself introduce new domain_id values into the binlog.

    When using multi-source replication, where a single replica connects to multiple primaries at the same time, each such primary should be configured with its own distinct domain ID.

    Similarly, in a multi-primary ring topology, where all primary in the ring are updated by the application concurrently (with some mechanism to avoid conflicts), a distinct domain ID should be configured for each server (In a multi-primary ring where the application is careful to only do updates on one primary at a time, a single domain ID is sufficient).

    Normally, a replica server should not receive direct updates (as this creates binlog differences compared to the primary). Thus it does not matter what value of gtid_domain_id is set on a replica, though it may make sense to make it the same as the primary (if not using multi-primary) to make it easy to promote the replica as a new primary. Of course, if a replica is itself an active primary, as in a multi-primary ring topology, the domain ID should be set according to the server's role as active primary.

    Note that domain ID and server ID are distinct concepts. It is possible to use a different domain ID on each server, but this is normally not desirable. It makes the current GTID position (@@global.gtid_slave_pos) more complicated to understand and work with, and loses the concept of a single ordered binlog stream across all servers. It is recommended only to configure as many domain IDs as there are primary servers actively being updated by the application at the same time.

    It is not an error in itself to configure domain IDs incorrectly (for example, not configuring them at all). For example, this will be typical in an upgrade scenario where a multi-primary ring using 5.5 is upgraded to 10.0. The ring will continue to work as before even though everything is configured to use the default domain ID 0. It is even possible to use GTID for replication between the servers. However, care must be taken when switching a replica to a different primary. If the binlog order between the old and the new primary differs, then a single GTID position to start replication from in the new primary's binlog may not be sufficient.

    Multiple Redundant Replication Paths

    Using GTID with multi-source replication, it is possible to set up multiple redundant replication paths. For example:

    Here, M1 and M2 are setup in a master-master ring. S1 and S2 both replicate from each of M1 and M2. Each event generated on M1 will now arrive twice at S1, through the paths M1->S1 and M1->M2->S1. This way, if the network connection between M1 and S1 is broken, the replication can continue uninterrupted through the alternate path through M2. Note that this is an advanced setup, and good familiarity with MariaDB replication is recommended to successfully operate it.

    The option must be enabled to use multiple redundant replication paths. This is necessary to avoid each event being applied twice on the replica as it arrives through each path. The GTID of every event will be compared against the sequence number of the current GTID replica position (within each domain), and will be skipped if less than or equal. Thus it is required that sequence numbers are strictly increasing within each domain for to function correctly, and setting to help enforce this is recommended.

    The --gtid-ignore-duplicates options also relaxes the requirement for connection to the master. In the above example, when S1 connects to M2, it may connect at a GTID position from M1 that has not yet been applied on M2.

    When --gtid-ignore-duplicates is enabled, the connection will be allowed, and S1 will start receiving events from M2 once the GTID has been replicated from M1 to M2. This can also be used to use replication filters in parts of a replication topology, to allow a replica to connect to a GTID position which was filtered on a master. When --gtid-ignore-duplicates is enabled, the connecting replica will start receiving events from the master at the first GTID sequence number that is larger than the connect-position.

    Deleting Unused Domains

    can be used to discard obsolete GTID domains from the server's binary log state. In order for this to be successful, no event group from the listed GTID domains can be present in existing binary log files. If some still exist, then they must be purged prior to executing this command.

    If the command completes successfully, then it also rotates the binary log.

    The old domains will still appear in . To get rid of these, you can stop the replica and execute on the replica:

    Additional Syntax For Global Transaction ID

    CHANGE MASTER

    has an option, master_use_gtid=[current_pos|slave_pos|no]. When enabled (set tocurrent_pos or slave_pos), the replica will connect to the master using the GTID position. When disabled (set to "no"), the old-style binlog filename/offset position is used to decide where to start replicating when connecting. Unlike in the old-style, when GTID is enabled, the values of the and options are not updated per received event in file.

    The value of master_use_gtid is saved across server restarts (in master.info). The current value can be seen as the field Using_Gtid in the output of SHOW SLAVE STATUS.

    For a detailed look at the difference between the current_pos and slave_pos options, see

    START SLAVE UNTIL master_gtid_pos=xxx

    When starting replication with , it is possible to request the replica to run only until a specific GTID position is reached. Once that position is reached, the replica will stop.

    The syntax for this is:

    START SLAVE UNTIL master_gtid_pos = <GTID position>

    The replica will start replication from the current GTID position, run up to and including the event with the GTID specified, and then stop. Note that this stops both the IO thread and the SQL thread (unlike START SLAVE UNTIL MASTER_LOG_FILE/MASTER_LOG_POS, which stops only the SQL thread).

    If multiple GTIDs are specified, then they must be with distinct replication domain ID, for example:

    START SLAVE UNTIL master_gtid_pos = "1-11-100,2-21-50"

    With multiple domains in the UNTIL condition, each domain runs only up to and including the specified position, so it is possible for different domains to stop at different places in the binlog (each domain will resume from the stopped position when the replica is started the next time).

    Not specifying a replication domain at all in the UNTIL condition means that the domain is stopped immediately, nothing is replicated from that domain. In particular, specifying the empty string will stop the replica immediately.

    When using START SLAVE UNTIL master_gtid_pos = XXX, if the UNTIL position is present in the primary's binlog then it is permissible for the start position to be missing on the primary. In this case, replication for the associated domains stop immediately.

    Both replica threads must be already stopped when using UNTIL master_gtid_pos, otherwise an error occurs. It is also an error if the replica is not configured to use GTID (CHANGE MASTER TO master_use_gtid=current_pos|slave_pos). And both threads must be started at the same time, the IO_THREAD or SQL_THREAD options can not be used to start only one of them.

    START SLAVE UNTIL master_gtid_pos=XXX is particularly useful for promoting a new primary among a set of replicas when the old master goes away and replicas may have reached different positions in the old primary's binlog. The new primary needs to be ahead of all the other replicas to avoid losing events. This can be achieved by picking one server, say S1, and replicating any missing events from each other server S2, S3, ..., Sn:

    Once this is completed, S1 will have all events present on any of the servers. It can now be selected as the new primary, and all the other servers set to replicate from it.

    MariaDB starting with

    SQL_BEFORE_GTIDS|SQL_AFTER_GTIDS

    extended the START SLAVE UNTIL command with the options SQL_BEFORE_GTIDS and SQL_AFTER_GTIDS to allow control of whether the replica stops before or after a provided GTID state. Its syntax is:

    When providing SQL_BEFORE_GTIDS=”<gtid_list>”, the replica will execute all transactions up to the first GTID found in the provided list, and stop immediately. In contrast to the default behavior of UNTIL, this will execute transactions from all domains on the primary until the replica stops due to seeing a GTID on the list. START SLAVE UNTIL SQL_AFTER_GTIDS=”<gtid_list>” is an alias to the default behavior of START SLAVE UNTIL master_gtid_pos=”<gtid_list>”. That is, the replica will only execute transactions originating from domain ids provided in the list, and will stop once all transactions provided in the UNTIL list have all been executed.

    Example

    If a primary server has a binary log consisting of the following GTIDs:

    • 0-1-1

    • 1-1-1

    • 0-1-2

    • 1-1-2

    If a fresh replica (i.e. one with an empty GTID position, @@gtid_slave_pos='') is started with SQL_BEFORE_GTIDS, i.e. START SLAVE UNTIL SQL_BEFORE_GTIDS=”1-1-2”, the resulting gtid_slave_pos of the replica will be “0-1-2,1-1-1”. This is because the replica will execute all events until it sees the transaction with GTID 1-1-2 and immediately stop without executing it. However, if a replica is started with SQL_AFTER_GTIDS, i.e. START SLAVE UNTIL SQL_AFTER_GTIDS=”1-1-2” then the resulting gtid_slave_pos of the replica will be “1-1-2”. This is because it will only execute events from domain 1 until it has executed the provided GTID.

    BINLOG_GTID_POS().

    The function takes as input an old-style position in the form of a file name and a file offset. It looks up the position in the current binlog, and returns a string representation of the corresponding GTID position. If the position is not found in the current binlog, NULL is returned.

    MASTER_GTID_WAIT

    The function is useful in replication for controlling primary/replica synchronization, and blocks until the replica has read and applied all updates up to the specified position in the primary log. See for details.

    Binlog Indexing

    MariaDB starting with

    Prior to , when a replica connects, MariaDB needs to scan files from the beginning in order to find the place to start replicating. If replica reconnects are frequent, this can be slow. introduces indexing on the binlog files, allowing GTIDs to be quickly found. This also detects if old-style replication tries to connect at an incorrect file offset (eg. in the middle of an event), avoiding sending potentially corrupted events. The feature is enabled by default. The size of the binlog index file (.idx) is generally less than 1% the size of the binlog, so should not have any negative impacts and should not normally need tuning. However, the feature can be disabled or managed with the following system variables:

    • - enable/disable the feature

    • - adjust the size of the pages

    • - adjust the sparseness of the index

    There are two status variables that can be used to monitor the effectiveness of the index:

    • - incremented for each successful lookup in a GTID index.

    • - incremented when a GTID index lookup is not possible, which indicates that the index file is missing (eg. binlog written by old server version without GTID index support), or corrupt.

    System Variables

    Enables/disables .

    Adjusts the size of the pages

    Adjusts the sparseness of the index

    gtid_slave_pos

    This system variable contains the GTID of the last transaction applied to the database by the server's for each replication domain. This system variable's value is automatically updated whenever a applies an event group. This system variable's value can also be manually changed by users, so that the user can change the GTID position of the .

    When using , the same GTID position is shared by all replica connections. In this case, different primaries should use different replication domains by configuring different values. If one primary was using a value of 1, and if another primary was using a value of 2, then any replicas replicating from both primaries would have GTIDs with both values in gtid_slave_pos.

    This system variable's value can be manually changed by executing , but all replica threads to be stopped with first. For example:

    This system variable's value can be reset by manually changing its value to the empty string. For example:

    The GTID position defined by gtid_slave_pos can be used as a replica's starting replication position by setting when the replica is configured with the statement. As an alternative, the system variable can also be used as a replica's starting replication position.

    If a user sets the value of the gtid_slave_pos system variable, and contains later GTIDs for certain replication domains, then will contain the GTIDs from for those replication domains. To protect users in this scenario, if a user sets the gtid_slave_pos system variable to a GTID position that is behind the GTID position in , then the server will give the user a warning.

    This can help protect the user when the replica is configured to use as its replication position. This can also help protect the user when a server has been rolled back to restart replication from an earlier point in time, but the user has forgotten to reset with .

    The system table is used to store the contents of global.gtid_slave_pos and preserve it over restarts.

    • Command line: None

    • Scope: Global

    • Dynamic: Yes

    • Data Type: string

    gtid_binlog_pos

    This variable is the GTID of the last event group written to the binary log, for each replication domain.

    Note that when the binlog is empty (such as on a fresh install with , or after ), there are no event groups written in any replication domain, so in this case the value of gtid_binlog_pos will be the empty string.

    The value is read-only, but it is updated whenever a DML or DDL statement is written to the binary log. The value can be reset by executing , which will also delete all binary logs. However, note that does not also reset . Since is the union of and gtid_binlog_pos, that means that new GTIDs added to gtid_binlog_pos can lag behind those in if contains GTIDs in the same domain with higher sequence numbers. If you want to reset for a specific GTID domain in cases like this, then you will also have to change in addition to executing . See for notes on how to change its value.

    • Command line: None

    • Scope: Global

    • Dynamic: Read-only

    • Data Type: string

    gtid_binlog_state

    The variable gtid_binlog_state holds the internal state of the binlog. The state consists of the last GTID ever logged to the binary log for every combination of domain_id and server_id. This information is used by the primary to determine whether a given GTID has been logged to the binlog in the past, even if it has later been deleted due to binlog purge. For each domain_id, the last entry in @@gtid_binlog_state is the last GTID logged into binlog, ie. this is the value that appears in @@gtid_binlog_pos.

    Normally this internal state is not needed by users, as @@gtid_binlog_pos is more useful in most cases. The main usage of @@gtid_binlog_state is to restore the state of the binlog after RESET MASTER (or equivalently if the binlog files are lost). If the value of @@gtid_binlog_state is saved before RESET MASTER and restored afterwards, the primary will retain information about past history, same as if PURGE BINARY LOGS had been used (of course the actual events in the binary logs are still deleted).

    Note that to set the value of @@gtid_binlog_state, the binary log must be empty, that is it must not contain any GTID events and the previous value of @@gtid_binlog_state must be the empty string. If not, then RESET MASTER must be used first to erase the binary log first.

    The value of @@gtid_binlog_state is preserved by the server across restarts by writing a file MASTER-BIN.state, where MASTER-BIN is the base name of the binlog set with the --log-bin option. This file is written at server shutdown, and re-read at next server start. (In case of a server crash, the data in the MASTER-BIN.state is not correct, and the server instead recovers the correct value during binlog crash recovery by scanning the binlog files and recording each GTID found).

    For completeness, note that setting @@gtid_binlog_state internally executes a RESET MASTER. This is normally not noticeable as it can only be changed when the binlog is empty of GTID events. However, if executed e.g. immediately after upgrading to MariaDB 10, it is possible that the binlog is non-empty but without any GTID events, in which case all such events will be deleted, just as if RESET MASTER had been run.

    • Command line: None

    • Scope: Global

    • Dynamic: Yes

    • Data Type: string

    gtid_current_pos

    This system variable contains the GTID of the last transaction applied to the database for each replication domain.

    The value of this system variable is constructed from the values of the and system variables. It gets GTIDs of transactions executed locally from the value of the system variable. It gets GTIDs of replicated transactions from the value of the system variable.

    For each replication domain, if the of the corresponding GTID in is equal to the servers own ,and the sequence number is higher than the corresponding GTID in , then the GTID from will be used. Otherwise the GTID from will be used for that domain.

    GTIDs from in which the of the GTID is not equal to the server's own are effectively ignored. If contains a GTID for a given replication domain, but the of the GTID is not equal to the server's own , and does not contain a GTID for that given replication domain, then gtid_current_pos will not contain any GTID for that replication domain.

    Thus, gtid_current_pos contains the most recent GTID executed on the server, whether this was done as a primary or as a replica.

    The GTID position defined by gtid_current_pos can be used as a replica's starting replication position by setting when the replica is configured with the statement. As an alternative, the system variable can also be used as a replica's starting replication position.

    The value of gtid_current_pos is read-only, but it is updated whenever a transaction is written to the binary log and/or replicated by a replica thread, and that transaction's GTID is considered newer than the current GTID for that domain. See above for the rules on how to determine if a GTID would be considered newer.

    If you need to reset the value, see the notes on resetting and , since gtid_current_pos is formed from the values of those variables.

    • Command line: None

    • Scope: Global

    • Dynamic: Read-only

    • Data Type: string

    gtid_strict_mode

    The GTID strict mode is an optional setting that can be used to help the DBA enforce a strict discipline about keeping binlogs identical across multiple servers replicating using global transaction ID.

    When GTID strict mode is enabled, some additional errors are enabled for situations that could otherwise cause differences between binlogs on different servers in a replication hierarchy:

    1. If a replica server tries to replicate a GTID with a sequence number lower than what is already in the binlog for that replication domain, the SQL thread stops with an error (this indicates an extra transaction in the replica binlog not present on the primary).

    2. Similarly, an attempt to manually binlog a GTID with a lower sequence number (by setting @@SESSION.gtid_seq_no) is rejected with an error.

    3. If the replica tries to connect starting at a GTID that is missing in the primary's binlog, this is an error in GTID strict mode even if a GTID exists with a higher sequence number (this indicates a GTID on the replica missing on the primary). Note that this error is controlled by the setting of GTID strict mode on the connecting replica server.

    GTID mode is off by default; this is needed to preserve backwards compatibility with existing replication setups (older versions of the server did not enforce any strict mode for binlog order). Global transaction ID is designed to work correctly even when strict mode is not enabled. However, with strict mode enforced, the semantics is simpler and thus easier to understand, because binlog order is always identical across servers and sequence numbers are always strictly increasing within each replication domain. This can also make automated scripting of large replication setups easier to implement correctly.

    When GTID strict mode is enabled, the replica will stop with an error when a problem is encountered. This allows the DBA to become aware of the problem and take corrective actions to avoid similar issues in the future. One way to recover from such an error is to temporarily disable GTID strict mode on the offending replica, to be able to replicate past the problem point (perhaps usingSTART SLAVE UNTIL master_gtid_pos=XXX).

    • Command line: --gtid-strict-mode[={0|1}]

    • Scope: Global

    • Dynamic: Yes

    • Data Type: boolean

    gtid_domain_id

    • Description: This variable is used to decide which replication domain new GTIDs are logged in for a primary server. See for details. This variable can also be set on the session level by a user with the SUPER privilege. This is used by to preserve the domain ID of GTID events.

    • Command line: --gtid-domain-id=#

    • Scope: Global, Session

    • Dynamic: Yes

    last_gtid

    • Description: Holds the GTID that was assigned to the last transaction, or statement that was logged to the . If the binary log is disabled, or if no transaction or statement was executed in the session yet, then the value is an empty string.

    • Scope: Session

    • Dynamic: Read-only

    • Data Type: string

    server_id

    • Description: Server_id can be set on the session level to change which server_id value is logged in binlog events (both GTID and other events). This is used by mariadb-binlog to preserve the server ID of GTID events.

    • Scope: Global, Session

    • Dynamic: Yes

    • Data Type: numeric (32-bit unsigned integer)

    gtid_seq_no

    • Description: gtid_seq_no can be set on the session level to change which sequence number is logged in the following GTID event. The variable, along with and , is typically used by to set up the gtid value of the transaction being decoded into the output.

    • Command line: None

    • Scope: Session

    • Dynamic: Yes

    gtid_ignore_duplicates

    • Description: When set, different primary connections in multi-source replication are allowed to receive and process event groups with the same GTID (when using GTID mode). Only one will be applied, any others will be ignored. Within a given replication domain, just the sequence number will be used to decide whether a given GTID has been already applied; this means it is the responsibility of the user to ensure that GTID sequence numbers are strictly increasing. With gtid_ignore_duplicates=OFF, a duplicate event based on domain id and sequence number, will be executed. When --gtid-ignore-duplicate is set, a replica is allowed to connect at a GTID position that does not exist on the primary. The replica will start receiving events once a GTID with a higher sequence number is available on the primary (within that domain). This can be used to allow a replica to connect at a GTID position that was filtered on the primary, eg. using . See also

    • Command line: --gtid-ignore-duplicates=#

    gtid_pos_auto_engines

    This variable is used to enable multiple versions of the table, one for each transactional storage engine in use. This can improve replication performance if a server is using multiple different storage engines in different transactions.

    The value is a list of engine names, separated by commas (','). Replication of transactions using these engines will automatically create new versions of the mysql.gtid_slave_pos table in the same engine and use that for future transactions (table creation takes place in a background thread). This avoids introducing a cross-engine transaction to update the GTID position. Only transactional storage engines are supported for gtid_pos_auto_engines (this currently means , , or ).

    The variable can be changed dynamically, but replica SQL threads should be stopped when changing it, and it will take effect when the replicas are running again.

    When setting the variable on the command line or in a configuration file, it is possible to specify engines that are not enabled in the server. The server will then still start if, for example, that engine is no longer used. Attempting to set a non-enabled engine dynamically in a running server (with SET GLOBAL gtid_pos_auto_engines) will still result in an error.

    Removing a storage engine from the variable will have no effect once the new tables have been created - as long as these tables are detected, they will be used.

    • Command line: --gtid-pos-auto-engines=value

    • Scope: Global

    • Dynamic: Yes

    • Data Type: string (comma-separated list of engine names)

    gtid_cleanup_batch_size

    • Description: Normally does not need tuning. How many old rows must accumulate in the before a background job will be run to delete them. Can be increased to reduce number of commits if using many different engines with , or to reduce CPU overhead if using a huge number of different . Can be decreased to reduce number of old rows in the table.

    • Command line: --gtid-cleanup-batch-size=#

    • Scope: Global

    See Also

    • binary logs

    This page is licensed: CC BY-SA / Gnu FDL

    0-1-3
  • 1-1-3

  • Default: Null

    Default: Null

    Default: Null

    Default: Null

    Default: Off

  • Data Type: numeric (32-bit unsigned integer)

  • Default Value: 0

  • Range: 0 to 4294967295

  • Data Type: numeric (64-bit unsigned integer)

  • Default: Null

  • Scope: Global
  • Dynamic: Yes

  • Data Type: boolean

  • Default: OFF

  • Default: empty

    Dynamic: Yes
  • Data Type: numeric

  • Default: 64

  • Range: 0 to 2147483647

  • Introduced:

  • Replication overview
    binary log
    binlog_format
    mysql.gtid_slave_pos
    CHANGE MASTER
    Use with multi-source replication and other multi-primary setups
    mariadb-binlog
    SHOW BINLOG EVENTS
    gtid_slave_pos
    CHANGE MASTER
    gtid_slave_pos
    gtid_slave_pos
    gtid_current_pos
    gtid_slave_pos
    CHANGE MASTER
    sql_log_bin
    GTID strict mode
    mysql.gtid_slave_pos table
    mysql_upgrade
    MyISAM
    ALTER TABLE
    mysql.gtid_slave_pos table
    gtid_pos_auto_engines
    mysql.gtid_slave_pos table
    MASTER_USE_GTID
    gtid_current_pos
    gtid_binlog_pos
    gtid_slave_pos
    gtid_slave_pos
    INSERT
    replica threads
    gtid_binlog_pos
    gtid_current_pos
    replica threads
    MASTER_USE_GTID
    parallel replication
    gtid_domain_id
    out-of-order
    CHANGE MASTER
    SHOW MASTER STATUS
    BINLOG_GTID_POS()
    gtid_slave_pos
    CHANGE MASTER
    replica threads
    START SLAVE
    server_id
    mysql.gtid_slave_pos
    mysql.gtid_slave_pos
    mysql.gtid_slave_pos
    mariadb-backup
    Percona XtraBackup
    Setting up a Replica with mariadb-backup
    mariadb-dump
    mariadb-dump
    --master-data
    --dump-slave
    gtid_slave_pos
    CHANGE MASTER
    --gtid
    --master-data
    --dump-slave
    Use with multi-source replication and other multi-primary setups
    GTID strict mode
    gtid_domain_id
    --gtid-ignore-duplicates
    --gtid-ignore-duplicates
    --gtid-strict-mode=1
    FLUSH BINARY LOGS DELETE_DOMAIN_ID=(list-of-domains)
    gtid_io_pos
    CHANGE MASTER
    MASTER_LOG_FILE
    MASTER_LOG_POS
    master_info_file
    Using global transaction IDs
    START SLAVE
    11.3.0
    BINLOG_GTID_POS()
    binary log
    MASTER_GTID_WAIT
    MASTER_GTID_WAIT
    11.4
    MariaDB 11.4
    binlog
    MariaDB 11.4
    binlog_gtid_index
    binlog_gtid_index_page_size
    binlog_gtid_index_span_min
    binlog_gtid_index_hit
    binlog_gtid_index_miss
    binlog_gtid_index
    binlog indexing
    binlog_gtid_index_page_size
    binlog_gtid_index_span_min
    replica threads
    replica thread
    replica threads
    multi-source replication
    gtid_domain_id
    gtid_domain_id
    gtid_domain_id
    gtid_domain_id
    SET GLOBAL
    STOP SLAVE
    MASTER_USE_GTID=slave_pos
    CHANGE MASTER TO
    gtid_current_pos
    gtid_binlog_pos
    gtid_current_pos
    gtid_binlog_pos
    gtid_binlog_pos
    gtid_current_pos
    gtid_binlog_pos
    RESET MASTER
    mysql.gtid_slave_pos
    --skip-test-db
    RESET MASTER
    RESET MASTER
    RESET MASTER
    gtid_slave_pos
    gtid_current_pos
    gtid_slave_pos
    gtid_current_pos
    gtid_slave_pos
    gtid_current_pos
    gtid_slave_pos
    RESET MASTER
    gtid_slave_pos
    gtid_binlog_pos
    gtid_slave_pos
    gtid_binlog_pos
    gtid_slave_pos
    server_id
    gtid_binlog_pos
    server_id
    gtid_slave_pos
    gtid_binlog_pos
    gtid_slave_pos
    gtid_binlog_pos
    server_id
    server_id
    gtid_binlog_pos
    server_id
    server_id
    gtid_slave_pos
    MASTER_USE_GTID=current_pos
    CHANGE MASTER TO
    gtid_slave_pos
    gtid_slave_pos
    gtid_binlog_pos
    Use with multi-source replication and other multi-primary setups
    mariadb-binlog
    binary log
    @@gtid_domain_id
    @@server_id
    mariadb-binlog
    --replicate-ignore-table
    Multiple Redundant Replication Paths
    mysql.gtid_slave_pos
    InnoDB
    TokuDB
    MyRocks
    mysql.gtid_slave_pos table
    gtid_pos_auto_engines
    gtid_domain_ids
    FLUSH
    Using MariaDB GTIDs with MariaDB Galera Cluster
    SELECT @@GLOBAL.gtid_slave_pos
    0-1-1
    SHOW SLAVE STATUS\G
    ...
    Using_Gtid: Slave_pos
    CHANGE MASTER TO MASTER_USE_GTID = slave_pos;
    START SLAVE;
    CHANGE MASTER TO 
     master_host="127.0.0.1", 
     master_port=3310, 
     master_user="root", 
     master_use_gtid=current_pos;
    START SLAVE;
    SELECT BINLOG_GTID_POS("master-bin.000001", 600);
    SET GLOBAL gtid_slave_pos = "0-1-2";
    CHANGE MASTER TO 
     master_host="127.0.0.1", 
     master_port=3310, 
     master_user="root", 
     master_use_gtid=slave_pos;
    START SLAVE;
    STOP SLAVE;
    CHANGE MASTER TO 
     master_host="127.0.0.1", 
     master_port=3310, 
     master_user="root", 
     master_use_gtid=current_pos;
    START SLAVE;
    STOP SLAVE;
    CHANGE MASTER TO 
     master_host='127.0.0.1', 
     master_port=3312;
    START SLAVE;
    M1 <-> M2
      M1 -> S1
      M1 -> S2
      M2 -> S1
      M2 -> S2
    SET gtid_slave_pos="<position WITH domains removed>"
    CHANGE MASTER TO master_host="S2";
        START SLAVE UNTIL master_gtid_pos = "<S2 GTID position>";
        ...
        CHANGE MASTER TO master_host="Sn";
        START SLAVE UNTIL master_gtid_pos = "<Sn GTID position>";
    START SLAVE UNTIL (SQL_BEFORE_GTIDS|SQL_AFTER_GTIDS)="<gtid_list>"
    STOP ALL SLAVES;
    SET GLOBAL gtid_slave_pos = "1-10-100,2-20-500";
    START ALL SLAVES;
    SET GLOBAL gtid_slave_pos = '';

    Replication and Binary Log System Variables

    Browse the reference for system variables that control replication behavior and binary logging. Use these settings to tune performance and behavior on primaries and replicas.

    The terms master and slave have historically been used in replication, and MariaDB has begun the process of adding primary and replica synonyms. The old terms will continue to be used to maintain backward compatibility - see MDEV-18777 to follow progress on this effort.

    This page lists system variables that are related to binary logging and replication.

    See Server System Variables for a complete list of system variables and instructions on setting them, as well as System variables for global transaction ID.

    Also see mariadbd replication options for related options that are not system variables (such as binlog_do_db and binlog_ignore_db).

    See also the .

    auto_increment_increment

    • Description: The increment for all values on the server, by default 1. Intended for use in primary-to-primary .

    • Command line: --auto-increment-increment[=#]

    • Scope: Global, Session

    auto_increment_offset

    • Description: The offset for all values on the server, by default 1. Intended for use in primary-to-primary . Should be not be larger than . See .

    • Command line: --auto-increment-offset[=#]

    • Scope: Global, Session

    binlog_alter_two_phase

    • Description: When set, split ALTER at binary logging into two statements: START ALTER and COMMIT/ROLLBACK ALTER. The ON setting is recommended for long-running ALTER-table so it could start on replica before its actual execution on primary.

    • Command line: --binlog-alter-two-phase[={0|1}]

    • Scope: Global, Session

    • Dynamic: Yes

    binlog_annotate_row_events

    • Description: This option tells the primary to write to the binary log.

    • Command line: --binlog-annotate-row-events[={0|1}]

    • Scope: Global, Session

    • Dynamic: Yes

    binlog_cache_size

    • Description: If the is active, this variable determines the size in bytes, per-connection, of the cache holding a record of binary log changes during a transaction. A separate variable, , sets the upper limit for the statement cache. The and will indicate whether this variable needs to be increased (you want a low ratio of binlog_cache_disk_use to binlog_cache_use).

    • Command line: --binlog-cache-size=#

    • Scope: Global

    binlog_checksum

    • Description: Specifies the type of BINLOG_CHECKSUM_ALG for log events in the .

    • Command line:

      • --binlog-checksum=name

      • --binlog-checksum=[0|1]

    binlog_commit_wait_count

    • Description: Configures the behavior of , which can help increase transaction throughput and is used to enable . With , the server can delay flushing a committed transaction into until the given number of transactions are ready to be flushed as a group. The delay will however not be longer than the value set by . The default value of 0 means that no delay is introduced. Setting this value can reduce I/O on the binary log and give an increased opportunity for parallel apply on the replica when is enabled, but too high a value will decrease the transaction throughput. By monitoring the status variable (>=) it is possible to see how often this is occurring.

    • Starting with and : If the server detects that one of the committing transactions T1 holds an row lock that another transaction T2 is waiting for, then the commit will complete immediately without further delay. This helps avoid losing throughput when many transactions need conflicting locks. This often makes it safe to use this option without losing throughput on a replica with , provided the value of is sufficiently high.

    binlog_commit_wait_usec

    • Description: Configures the behavior of , which can help increase transaction throughput and is used to enable . With , the server can delay flushing a committed transaction into until the transaction has waited the configured number of microseconds. By monitoring the status variable (>=) it is possible to see how often group commits are made due to binlog_commit_wait_usec. As soon as the number of pending commits reaches , the wait will be terminated, though. Thus, this setting only takes effect if binlog_commit_wait_count is non-zero.

    • Command line: --binlog-commit-wait-usec#

    binlog_direct_non_transactional_updates

    • Description: inconsistencies can occur due when a transaction updates both transactional and non-transactional tables and the updates to the non-transactional tables are visible before being written to the binary log. This is because, to preserve causality, the non-transactional statements are written to the transaction cache, which is only flushed on commit. Setting binlog_direct_non_transactional_updates to 1 (0 is default) will cause non-transactional tables to be written straight to the binary log, rather than the transaction cache. This setting has no effect when row-based binary logging is used, as it requires statement-based logging. See . Use with care, and only in situations where no dependencies exist between the non-transactional and transactional tables, for example INSERTing into a non-transactional table based upon the results of a SELECT from a transactional table.

    • Command line: --binlog-direct-non-transactional-updates[=value]

    • Scope: Global, Session

    binlog_do_db

    • Description: This option allows you to configure a to write statements and transactions affecting databases that match a specified name into its . Since the filtered statements or transactions will not be present in the , its replicas will not be able to replicate them.

      • This option will not work with cross-database updates with . See the section for more information.

      • Until , only available as an option, not a system variable. This option can not be set dynamically.

    binlog_expire_logs_seconds

    • Description: If non-zero, binary logs will be purged after binlog_expire_logs_seconds seconds. Possible purges happen at startup and at binary log rotation. From , binlog_expire_logs_seconds and are forms of aliases, such that changes to one automatically reflect in the other.

    • Command line: --binlog-expire-logs-seconds=#

    • Scope: Global

    binlog_file_cache_size

    • Description: Size of in-memory cache that is allocated when reading and files.

    • Command line: --binlog-file-cache-size=#

    • Scope: Global, Session

    • Dynamic: Yes

    binlog_format

    • Description: Determines whether is row-based, statement-based or mixed. Statement-based was the default until . Be careful of changing the binary log format when a replication environment is already running. See . Starting from a replica will apply any events it gets from the primary, regardless of the binary log format. binlog_format only applies to normal (not replicated) updates.

    • Command line: --binlog-format=format

    • Scope: Global, Session

    binlog_gtid_index

    • Description: Enable the creation of a GTID index for every binlog file, and the use of such index for speeding up GTID lookup in the binlog. See .

    • Command line: --binlog-gtid-index{=0|1}

    • Scope: Global

    • Dynamic: Yes

    binlog_gtid_index_page_size

    • Description: Page size to use for the binlog GTID index. See .

    • Command line: --binlog-gtid-index-page-size=#

    • Scope: Global

    • Dynamic: Yes

    binlog_gtid_index_span_min

    • Description: Control sparseness of the binlog GTID index. If set to N, at most one index record will be added for every N byte of binlog file written, to reduce the size of the index. Normally does not need tuning. See .

    • Command line: --binlog-gtid-index-span-min=#

    • Scope: Global

    • Dynamic: Yes

    binlog_ignore_db

    • Description: This option allows you to configure a to not write statements and transactions affecting databases that match a specified name into its . Since the filtered statements or transactions will not be present in the , its replicas will not be able to replicate them.

      • This option will not work with cross-database updates with . See the section for more information.

      • Until , only available as an option, not a system variable. This option cannot be set dynamically.

    binlog_large_commit_threshold

    • Description: Increases transaction concurrency for large transactions (i.e. those with sizes larger than this value) by using the large transaction's cache file as a new binary log and rotating the active binary log to the large transaction's cache file at commit time. This avoids the default commit logic that copies the transaction cache data to the end of the active binary log file while holding a lock that prevents other transactions from binlogging.

    • Command line: --binlog-large-commit-threshold=val

    • Scope: Global

    binlog_legacy_event_pos

    • Description: Fill in the end_log_pos field of all events in the binlog, even when doing so costs performance. Can be used in case some old application needs it for backwards compatibility. Setting this option can hurt binlog scalability.

    • Command line: --binlog-legacy-event-pos{=0|1}

    • Scope: Global

    • Dynamic: Yes

    binlog_optimize_thread_scheduling

    • Description: Run fast part of group commit in a single thread, to optimize kernel thread scheduling. On by default. Disable to run each transaction in group commit in its own thread, which can be slower at very high concurrency. This option is mostly for testing one algorithm versus another, and it should not normally be necessary to change it. Deprecated in , as the option was initially added to provide a safe alternative for the newly added binlog group commit logic, such that when 0, it would disable a leader thread from performing the binlog write for all transactions that are a part of the group commit. Problems related to the binlog group commit optimization are expected to be addressed by now, so the option has been deprecated and will be removed in future.

    • Command line: --binlog-optimize-thread-scheduling or --skip-binlog-optimize-thread-scheduling

    binlog_row_event_max_size

    • Description: The maximum size of a row-based event in bytes. Rows will be grouped into events smaller than this size if possible. The value has to be a multiple of 256. Until , only available as an option, not a system variable.

    • Command line: --binlog-row-event-max-size=val

    • Scope: Global, Session

    • Dynamic: Yes

    binlog_row_image

    • Description: Controls the logging format in . In row-based replication (the variable has no effect with ), each row change event contains an image for matching against when choosing the row to be updated, and another image containing the changes. Before the introduction of this variable, all columns were logged for both of these images. In certain circumstances, this is not necessary, and memory, disk and network resources can be saved by partial logging. Note that to safely change this setting from the default, the table being replicated to must contain identical primary key definitions, and columns must be present, in the same order, and use the same data types as the original table. If these conditions are not met, matches may not be correctly determined and updates and deletes may diverge on the replica, with no warnings or errors returned.

      • FULL: All columns in the before and after image are logged. This is the default, and the only behavior in earlier versions.

    binlog_row_metadata

    • Description: Controls the format used for binlog metadata logging.

      • NO_LOG: No metadata is logged (default).

      • MINIMAL: Only metadata required by a replica is logged.

    binlog_space_limit

    • Description: Alias for .

    • Introduced:

    binlog_stmt_cache_size

    • Description: If the is active, this variable determines the size in bytes of the cache holding a record of binary log changes outside of a transaction. The variable , determines the cache size for binary log statements inside a transaction. The and will indicate whether this variable needs to be increased (you want a low ratio of binlog_stmt_cache_disk_use to binlog_stmt_cache_use).

    • Command line: --binlog-stmt-cache-size=#

    • Scope: Global

    create_tmp_table_binlog_formats

    • Description: The under which the primary will log CREATE TEMPORARY statments to the . If CREATE TEMPORARY is not logged, all usage of the temporary table will be logged in ROW format. Allowed values are STATEMENT or MIXED,STATEMENT.

    • Command line: --create-tmp-table-binlog-formats=#

    • Scope: Global, Session

    • Dynamic: Yes

    default_master_connection

    • Description: In , specifies which connection will be used for commands and variables if you don't specify a connection.

    • Command line: None

    • Scope: Session

    • Dynamic: Yes

    encrypt_binlog

    • Description: Encrypt (including ). See and .

    • Command line: --encrypt-binlog[={0|1}]

    • Scope: Global

    • Dynamic: No

    expire_logs_days

    • Description: Number of days after which the can be automatically removed. By default, 0, or no automatic removal. When using , should always be set higher than the maximum lag by any replica. Removals take place when the server starts up, when the binary log is flushed, when the next binary log is created after the previous one reaches the maximum size, or when running . Units are whole days (integer) until , or 1/1000000 precision (double) from . Starting from , expire_logs_days and are forms of aliases, such that changes to one automatically reflect in the other. Some container configs explicitly set expire_logs_days to 10, rather than leave it as the default, zero.

    • Command line: --expire-logs-days=#

    init_slave

    • Description: Similar to , but the string contains one or more SQL statements, separated by semicolons, that will be executed by a replica server each time the SQL thread starts. These statements are only executed after the acknowledgement is sent to the replica and completes.

    • Command line: --init-slave=name

    • Scope: Global

    • Dynamic: Yes

    log_bin

    • Description: Whether is enabled or not. If the --log-bin is used, log_bin will be set to ON, otherwise it will be OFF. If no name option is given for --log-bin, datadir/'log-basename'-bin or 'datadir'/mysql-bin will be used (the latter if is not specified). We strongly recommend you use either --log-basename or specify a filename to ensure that doesn't stop if the real hostname of the computer changes. The name option can optionally include an absolute path. If no path is specified, the log will be written to the . The name can optionally include the file extension; it will be stripped and only the file basename will be used.

    log_bin_basename

    • Description: The full path of the binary log file names, excluding the extension. Its value is derived from the rules specified in log_bin system variable. This is a read-only variable only, there is no corresponding configuration file setting or command line option by the same name, use log_bin to set the basename path instead.

    • Command line: No commandline option

    • Scope: Global

    log_bin_compress

    • Description: Whether or not the binary log can be compressed. 0 (the default) means no compression. See .

    • Command line: --log-bin-compress

    • Scope: Global

    • Dynamic: Yes

    log_bin_compress_min_len

    • Description: Minimum length of sql statement (in statement mode) or record (in row mode) that can be compressed. See .

    • Command line: --log-bin-compress-min-len

    • Scope: Global

    • Dynamic: Yes

    log_bin_index

    • Description: File that holds the names for last binlog files. If is also set, log_bin_index should be placed after in the config files. Later settings override earlier settings, so log-basename will override any earlier log file name settings.

    • Command line: --log-bin-index=name

    • Scope: Global

    log_bin_trust_function_creators

    • Description: Functions and triggers can be dangerous when used with . Certain types of functions and triggers may have unintended consequences when the statements are applied on a replica. For that reason, there are some restrictions on the creation of functions and triggers when the is enabled by default, such as:

      • When log_bin_trust_function_creators is OFF and is ON, and statements will trigger an error if the function is defined with any of the NOT DETERMINISTIC, CONTAINS SQL

    log_slow_slave_statements

    • Description: Log slow statements executed by replica thread to the if it is open. Before , this was only available as a mariadbd option, not a server variable.

    • Command line: --log-slow-slave-statements

    • Scope: Global

    • Dynamic: Yes

    log_slave_updates

    • Description: If set to 0, the default, updates on a replica received from a primary during are not logged in the replica's binary log. If set to 1, they are. The replica's binary log needs to be enabled for this to have an effect. Set to 1 if you want to daisy-chain the replicas.

    • Command line: --log-slave-updates

    • Scope: Global

    master_info_file

    • Description: The location and name of the file that remembers the master and where the I/O replication thread is in the master's binlogs. Defaults to master.info.

    • Command line: --master-info-file=val

    • Scope: Global

    • Dynamic: No

    master_verify_checksum

    • Description: Verify when reading events from the binlog on the primary.

    • Command line: --master-verify-checksum=[0|1]

    • Scope: Global

    • Access Type: Can be changed dynamically

    max_binlog_cache_size

    • Description: Restricts the size in bytes used to cache a multi-transactional query. If more bytes are required, a Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage error is generated. If the value is changed, current sessions are unaffected, only sessions started subsequently. See and .

    • Command line: --max-binlog-cache-size=#

    • Scope: Global

    max_binlog_size

    • Description: If the exceeds this size in bytes after a write, the server rotates it by closing it and opening a new binary log. Single transactions will always be stored in the same binary log, so the server will wait for open transactions to complete before rotating. This figure also applies to the size of if is set to zero.

    • Command line: --max-binlog-size=#

    • Scope: Global

    max_binlog_stmt_cache_size

    • Description: Restricts the size used to cache non-transactional statements. See and .

    • Command line: --max-binlog-stmt-cache-size=#

    • Scope: Global

    • Dynamic: Yes

    max_binlog_total_size

    • Description: Maximum space in bytes to use for all . Extra logs are deleted on server start, log rotation, FLUSH LOGS or when writing to binlog. Default is 0, which means no size restrictions. See also .

    • Command line: --max-binlog-size=#

    • Scope: Global

    • Dynamic: Yes

    max_relay_log_size

    • Description: Replica will rotate its if it exceeds this size after a write. If set to 0, the setting is used instead. Previously global only, since the implementation of , it can be set per session as well.

    • Command line: --max-relay-log-size=#

    • Scope: Global, Session

    • Dynamic: Yes

    read_binlog_speed_limit

    • Description: Used to restrict the speed at which a can read the binlog from the primary. This can be used to reduce the load on a primary if many replicas need to download large amounts of old binlog files at the same time. The network traffic will be restricted to the specified number of kilobytes per second.

    • Command line: --read-binlog-speed-limit=#

    • Scope: Global

    • Dynamic: Yes

    relay_log

    • Description: basename. If not set, the basename of the files will be hostname-relay-bin, or derived from . If is also set, relay_log should be placed after in the config files. Later settings override earlier settings, so log-basename will override any earlier log file name settings.

    • Command line: --relay-log=file_name

    relay_log_basename

    • Description: The full path of the relay log file names, excluding the extension. Its value is derived from the variable value.

    • Command line: No commandline option

    • Scope: Global

    • Dynamic: No

    relay_log_index

    • Description: Name and location of the index file, the file that keeps a list of the last relay logs. Defaults to hostname-relay-bin.index, or derived from . If is also set, relay_log_index should be placed after in the config files. Later settings override earlier settings, so log-basename will override any earlier log file name settings.

    • Command line: --relay-log-index=name

    • Scope: Global

    relay_log_info_file

    • Description: Name and location of the file where the RELAY_LOG_FILE and RELAY_LOG_POS options (i.e. the position) for the statement are written. The keeps this position updated as it applies events.

      • See for more information.

    • Command line: --relay-log-info-file=file_name

    relay_log_purge

    • Description: If set to 1 (the default), will be purged as soon as they are no longer necessary.

    • Command line: --relay-log-purge={0|1}

    • Scope: Global

    • Dynamic: Yes

    relay_log_recovery

    • Description: If set to 1 (0 is default), on startup the replica will drop all that haven't yet been processed, and retrieve relay logs from the primary. Can be useful after the replica has crashed to prevent the processing of corrupt relay logs. relay_log_recovery should always be set together with . Setting relay-log-recovery=1 with relay-log-purge=0 can cause the relay log to be read from files that were not purged, leading to data inconsistencies.

    • Command line: --relay-log-recovery

    relay_log_space_limit

    • Description: Specifies the maximum space to be used for the . The IO thread will stop until the SQL thread has cleared the backlog. By default 0, or no limit.

    • Command line: --relay-log-space-limit=#

    • Scope: Global

    replicate_annotate_row_events

    • Description: Tells the replica to reproduce received from the primary in its own binary log. This option is sensible only when used in tandem with the option.

    • Command line: --replicate-annotate-row-events

    • Scope: Global

    • Dynamic: No

    replicate_do_db

    • Description: This system variable allows you to configure a to apply statements and transactions affecting databases that match a specified name.

      • This system variable will not work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    replicate_do_table

    • Description: This system variable allows you to configure a to apply statements and transactions that affect tables that match a specified name. The table name is specified in the format: dbname.tablename.

      • This system variable will not work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    replicate_events_marked_for_skip

    • Description: Tells the replica whether to events that are marked with the @@skip_replication flag. See for more information.

    • Command line: --replicate-events-marked-for-skip

    • Scope: Global

    replicate_ignore_db

    • Description: This system variable allows you to configure a to ignore statements and transactions affecting databases that match a specified name.

      • This system variable will not work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    replicate_ignore_table

    • Description: This system variable allows you to configure a to ignore statements and transactions that affect tables that match a specified name. The table name is specified in the format: dbname.tablename.

      • This system variable will not work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    replicate_rewrite_db

    • Description: This option allows you to configure a to rewrite database names. It uses the format primary_database->replica_database. If a replica encounters a event in which the default database (i.e. the one selected by the statement) is primary_database, then the replica will apply the event in replica_database instead.

      • This option will not work with cross-database updates with . See the section for more information.

    replicate_same_server_id

    • Description: In replication, if set to 1, do not skip events having our server id. Default value is 0 (to break infinite loops in circular replication). Can't be set to 1 if is used

    • Command line: --replicate-same-server-id[={0|1}]

    • Scope: Global

    • Dynamic: No

    replicate_wild_do_table

    • Description: This system variable allows you to configure a to apply statements and transactions that affect tables that match a specified wildcard pattern. The wildcard pattern uses the same semantics as the operator.

      • This system variable will work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    replicate_wild_ignore_table

    • Description: This system variable allows you to configure a to ignore statements and transactions that affect tables that match a specified wildcard pattern. The wildcard pattern uses the same semantics as the operator.

      • This system variable will work with cross-database updates with . See the section for more information.

      • When setting it dynamically with , the system variable accepts a comma-separated list of filters.

    report_host

    • Description: The host name or IP address the replica reports to the primary when it registers. If left unset, the replica will not register itself. Reported by . Note that it is not sufficient for the primary to simply read the IP of the replica from the socket once the replica connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the replica from the primary or other hosts.

    • Command line: --report-host=host_name

    • Scope: Global

    report_password

    • Description: Replica password reported to the primary when it registers. Reported by if --show-slave-auth-info is set. This password has no connection with user privileges or with the user account password.

    • Command line: --report-password=password

    • Scope: Global

    report_port

    • Description: The command line option sets the TCP/IP port for connecting to the replica that will be reported to the primary during the replica's registration. Viewing the variable will show this value.

    • Command line: --report-port=#

    • Scope: Global

    • Dynamic: No

    report_user

    • Description: Replica's account user name reported to the primary when it registers. Reported by if --show-slave-auth-info is set. This username has no connection with user privileges or with the user account.

    • Command line: --report-user=name

    • Scope: Global

    server_id

    • Description: This system variable is used with to identify unique primary and replica servers in a topology. This system variable is also used with the to determine which server a specific transaction originated on.

      • When is used with standalone MariaDB Server, each server in the replication topology must have a unique server_id value.

      • When is used with , see for more information on how to set the server_id values.

    show_slave_auth_info

    • Description: Show user and password in (SHOW SLAVE HOSTS) on this primary.

    • Command line: --show-slave-auth-info[={0|1}]

    • Scope: Global

    • Dynamic: No

    skip_parallel_replication

    • Description: If set when a transaction is written to the binlog, parallel apply of that transaction will be avoided on a replica where is not aggressive. Can be used to avoid unnecessary rollback and retry for transactions that are likely to cause a conflict if replicated in parallel. See .

    • Command line: None

    • Scope: Session

    skip_replication

    • Description: Changes are logged into the with the @@skip_replication flag set. Such events will not be by replica that run with --replicate-events-marked-for-skip set different from its default of REPLICATE. See for more information.

    • Command line: None

    • Scope: Session

    slave_abort_blocking_timeout

    • Description: Maximum time a replica DDL will wait for a blocking SELECT or other user query until that query will be aborted. The argument will be treated as a decimal value with nanosecond precision. The variable is intended to solve a problem where a long-running SELECT on a replica causes DDL to wait for that SELECT to complete, potentially causing massive replica lag.

    • Command line: --slave-abort-blocking-timeout=num

    • Scope: Global

    slave_compressed_protocol

    • Description: If set to 1 (0 is the default), will use compression for the replica/primary protocol if both primary and replica support this.

    • Command line: --slave-compressed-protocol

    • Scope: Global

    • Dynamic: Yes

    slave_connections_needed_for_purge

    • Description: Minimum number of connected replicas required for automatic purge with , or . Change of the value triggers an attempt to purging, though without binlog rotation, with the purged set of files satisfying the above two parameters and the value that is set itself.

    • Command line: --slave-connections-needed-for-purge=#

    • Scope: Global

    slave_ddl_exec_mode

    • Description: Modes for how of DDL events should be executed. Legal values are STRICT and IDEMPOTENT (default). In IDEMPOTENT mode, the replica will not stop for failed DDL operations that would not cause a difference between the primary and the replica. In particular is treated as and is treated as DROP TABLE IF EXISTS.

    • Command line: --slave-ddl-exec-mode=name

    slave_domain_parallel_threads

    • Description: When set to a non-zero value, each domain in one primary connection can reserve at most that many worker threads at any one time, leaving the rest (up to the value of ) free for other primary connections or replication domains to use in parallel. See for details.

    • Command line: --slave-domain-parallel-threads=#

    • Scope: Global

    slave_exec_mode

    • Description: Determines the mode used for error checking and conflict resolution. STRICT mode is the default, and catches all errors and conflicts. IDEMPOTENT mode suppresses duplicate key or no key errors, which can be useful in certain replication scenarios, such as when there are multiple primaries, or circular replication.

    • Scope: Global

    • Dynamic: Yes

    • Data Type: enumeration

    slave_load_tmpdir

    • Description: Directory where the replica stores temporary files for statements. If not set, the replica will use . Should be set to a disk-based directory that will survive restarts, or else replication may fail.

    • Command line: --slave-load-tmpdir=path

    • Scope: Global

    • Dynamic: No

    slave_max_allowed_packet

    • Description: Maximum packet size in bytes for replica SQL and I/O threads. This value overrides for purposes. Set in multiples of 1024 (the minimum) up to 1GB

    • Command line: --slave-max-allowed-packet=#

    • Scope: Global

    • Dynamic: Yes

    slave_max_statement_time

    • Description: A query that has taken more than this in seconds to run on the replica will be aborted. The argument will be treated as a decimal value with microsecond precision. A value of 0 (default) means no timeout.

    • Command line: --slave-max-statement-time=#

    • Scope: Global

    • Dynamic: Yes

    slave_net_timeout

    • Description: Time in seconds for the replica to wait for more data from the primary before considering the connection broken, after which it will abort the read and attempt to reconnect. The retry interval is determined by the MASTER_CONNECT_RETRY open for the statement, while the maximum number of reconnection attempts is set by the option. The first reconnect attempt takes place immediately.

    • Command line: --slave-net-timeout=#

    • Scope: Global

    slave_parallel_max_queued

    • Description: When is used, the will read ahead in the relay logs, queueing events in memory while looking for opportunities for executing events in parallel. This system variable sets a limit for how much memory it will use for this.

      • The configured value of this system variable is actually allocated for each , so the total allocation is actually equivalent to the following:

        • *

    slave_parallel_mode

    • Description: Controls what transactions are applied in parallel when using .

      • optimistic: tries to apply most transactional DML in parallel and handles any conflicts with rollback and retry. See .

      • conservative: limits parallelism in an effort to avoid any conflicts. See .

    slave_parallel_threads

    • Description: This system variable is used to configure .

      • If this system variable is set to a value greater than 0, then its value will determine how many replica will be created to apply events in parallel.

      • If this system variable is set to 0 (which is the default value), then no replica will be created. Instead, when replication is enabled, events are applied by the replica's .

    slave_parallel_workers

    • Description: Alias for .

    • Command line: --slave-parallel-workers=#

    slave_run_triggers_for_rbr

    • Description: See for a description and use-case for this setting.

    • Command line: --slave-run-triggers-for-rbr=value

    • Scope: Global

    • Dynamic: Yes

    slave_skip_errors

    • Description: When an error occurs on the replica, usually halts. This option permits a list of to ignore, and for which replication will continue. This option should never be needed in normal use, and careless use could lead to replica that are out of sync with primaries. Error codes are in the format of the number from the replica error log. Using all as an option permits the replica the keep replicating no matter what error it encounters, an option you would never normally need in production, and which could rapidly lead to data inconsistencies. A count of these is kept in .

    • Command line: --slave-skip-errors=[error_code1,error_code2,...|all|ddl_exist_errors]

    • Scope: Global

    slave_sql_verify_checksum

    • Description: Verify when the replica SQL thread reads events from the .

    • Command line: --slave-sql-verify-checksum=[0|1]

    • Scope: Global

    • Access Type: Can be changed dynamically

    slave_transaction_retries

    • Description: Number of times a replica retries to execute an SQL thread after it fails due to InnDB deadlock or by exceeding the transaction execution time limit. If after this number of tries the SQL thread has still failed to execute, the replica will stop with an error. See also the system variable.

    • Command line: --slave-transaction-retries=#

    • Scope: Global

    slave_transaction_retry_errors

    • Description: When an error occurs during a transaction on the replica, usually halts. By default, transactions that caused a deadlock or elapsed lock wait timeout will be retried. One can add other errors to the list of errors that should be retried by adding a comma-separated list of to this variable. This is particularly useful in some setups. Some recommended errors to retry for Spider are 1020, 1158, 1159, 1160, 1161, 1429, 2013, 12701 (these are in the default value in recent versions).

    • Command line: --slave-transaction_retry-errors=[error_code1,error_code2,...]

    • Scope: Global

    slave_transaction_retry_interval

    • Description: Interval in seconds for the replica SQL thread to retry a failed transaction due to a deadlock, elapsed lock waits timeout or an error listed in . The interval is calculated as max(slave_transaction_retry_interval, min(retry_count, 5)).

    • Command line: --slave-transaction-retry-interval=#

    • Scope: Global

    slave_type_conversions

    • Description: Determines the type conversion mode on the replica when using , including replications in MariaDB Galera cluster. Multiple options can be set, delimited by commas. If left empty, the default, type conversions are disallowed. The variable is dynamic and a change in its value takes effect immediately. This variable tells the server what to do if the table definition is different between the primary and replica (for example a column is 'int' on the primary and 'bigint' on the replica).

      • ALL_NON_LOSSY means that all safe conversions (no data loss) are allowed.

      • ALL_LOSSY means that all lossy conversions are allowed (for example 'bigint' to 'int'). This, however, does not imply that safe conversions (non-lossy) are allowed as well. In order to allow all conversions, one needs to allow both lossy as well as non-lossy conversions by setting this variable to ALL_NON_LOSSY,ALL_LOSSY.

    sql_log_bin

    • Description: If set to 0 (1 is the default), no logging to the is done for the client. Only clients with the SUPER privilege can update this variable. Does not affect the replication of events in a Galera cluster. Note that sql_log_bin has no effect if is not set.

    • Scope: Session

    • Dynamic: Yes

    • Data Type:

    sql_slave_skip_counter

    • Description: Number of events that a replica skips from the primary. If this would cause the replica to begin in the middle of an event group, the replica will instead begin from the beginning of the next event group. See .

    • Scope: Global

    • Dynamic: Yes

    • Data Type: numeric

    sync_binlog

    • Description: MariaDB will synchronize its binary log file to disk after this many events. The default is 0, in which case the operating system handles flushing the file to disk. 1 is the safest, but slowest, choice, since the file is flushed after each write. If autocommit is enabled, there is one write per statement, otherwise there's one writes per transaction. If the disk has cache backed by battery, synchronization will be fast, and a more conservative number can be chosen.

    • Command line: --sync-binlog=#

    • Scope: Global

    sync_master_info

    • Description: A replica will synchronize its master.info file to disk after this many events. If set to 0, the operating system handles flushing the file to disk.

    • Command line: --sync-master-info=#

    • Scope: Global

    • Dynamic: Yes

    sync_relay_log

    • Description: The MariaDB server will synchronize its to disk after this many writes to the log. The default until was 0, in which case the operating system handles flushing the file to disk. 1 is the safest, but slowest, choice, since the file is flushed after each write. If autocommit is enabled, there is one write per statement, otherwise there's one write per transaction. If the disk has cache backed by battery, synchronization will be fast and a more conservative number can be chosen.

    • Command line: --sync-relay-log=#

    • Scope: Global

    sync_relay_log_info

    • Description: A replica will synchronize its relay-log.info file to disk after this many transactions. The default until was 0, in which case the operating system handles flushing the file to disk. 1 is the most secure choice, because at most one event could be lost in the event of a crash, but it's also the slowest.

    • Command line: --sync-relay-log-info=#

    • Scope: Global,

    This page is licensed: CC BY-SA / Gnu FDL

    Dynamic: Yes
  • Data Type: numeric

  • Default Value: 1

  • Range: 1 to 65535

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 1

  • Range: 1 to 65535

  • Data Type: boolean

  • Default Value: OFF

  • Introduced:

  • Data Type: boolean

  • Default Value: ON

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 32768

  • Range - 32 bit: 4096 to 4294967295

  • Range - 64 bit: 4096 to 18446744073709547520

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: CRC32

  • Valid Values: NONE (0), CRC32 (1)

  • Command line: --binlog-commit-wait-count=#]

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 18446744073709551615

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 100000

  • Range: 0 to 18446744073709551615

  • Dynamic: Yes

  • Data Type: boolean

  • Default Value: OFF (0)

  • When setting it on the command-line or in a server option group in an option file, the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times.

  • See Replication Filters for more information.

  • Command line: --binlog-do-db=#

  • Scope: Global

  • Dynamic: No

  • Data Type: string

  • Default Value: NULL

  • Introduced: (as a system variable)

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 8553600

  • Introduced:

  • Data Type: numeric

  • Default Value: 16384

  • Range: 8192 to 18446744073709551615

  • Dynamic: Yes

  • Data Type: enumeration

  • Default Value: MIXED

  • Valid Values: ROW, STATEMENT or MIXED

  • Data Type: boolean

  • Default Value: ON

  • Introduced:

  • Data Type: numeric

  • Default Value: 4096

  • Range: 64 to 16777216

  • Introduced:

  • Data Type: numeric

  • Default Value: 65536

  • Range: 1 to 1073741824

  • Introduced:

  • When setting it on the command-line or in a server option group in an option file, the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times.

  • See Replication Filters for more information.

  • Command line: --binlog-ignore-db=name

  • Scope: Global

  • Dynamic: No

  • Data Type: string

  • Default Value: NULL

  • Introduced:

  • Dynamic: Yes
  • Data Type: bigint unsigned

  • Default Value: 134217728

  • Range: 10485760 to 18446744073709551615

  • Introduced:

  • Data Type: boolean

  • Default Value: OFF

  • Introduced:

  • Scope: Global
  • Dynamic: No

  • Data Type: boolean

  • Default Value: ON

  • Deprecated:

  • Data Type: numeric

  • Default Value: 8192

  • Range: 256 to 4294967040 (in multiples of 256)

  • Introduced:

  • NOBLOB: mariadbd avoids logging blob and text columns whenever possible (eg, blob column was not changed or is not part of primary key).

  • MINIMAL: A PK equivalent (PK columns or full row if there is no PK in the table) is logged in the before image, and only changed columns are logged in the after image.

  • FULL_NODUP: All columns are logged in the before image but only changed columns or all columns of inserted record are logged in the after image. This is essentially the same as FULL, but takes less space. From .

  • Command line: --binlog-row-image=value

  • Scope: Global, Session

  • Dynamic: Yes

  • Data Type: enum

  • Default Value: FULL

  • Valid Values:

    • <= : FULL, NOBLOB or MINIMAL

    • >=: FULL, NOBLOB, MINIMAL or FULL_NODUP

  • FULL: All metadata is logged.
  • Command line: --binlog-row-metadata=value

  • Scope: Global

  • Dynamic: Yes

  • Data Type: enum

  • Default Value: NO_LOG

  • Valid Values: NO_LOG, MINIMAL, FULL

  • Introduced:

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 32768

  • Range - 32 bit: 4096 to 4294967295

  • Range - 64 bit: 4096 to 18446744073709547520

  • Data Type: enum

  • Default Value: STATEMENT

  • Valid Values: STATEMENT or MIXED,STATEMENT

  • Introduced:

  • Data Type: string

  • Default Value: '' (empty string)

  • Data Type: boolean

  • Default Value: OFF

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 0.000000 (>= ), 0 (<= )

  • Range: 0 to 99

  • Data Type: string

  • Related variables: init_connect

  • Command line:
    --log-bin[=name]
  • Scope: Global

  • Dynamic: No

  • Data Type: boolean

  • Default Value: OFF

  • Related variables: sql_log_bin

  • Dynamic: No

  • Data Type: string

  • Default Value: None

  • Dynamic: No

  • Data Type: boolean

  • Default Value: OFF

  • Data Type: numeric

  • Default Value: 256

  • Range: 10 to 1024

  • Dynamic: No

  • Data Type: string

  • Default Value: None

  • or
    MODIFIES SQL DATA
    characteristics.
  • This means that when log_bin_trust_function_creators is OFF and log_bin is ON, CREATE FUNCTION and ALTER FUNCTION statements will only succeed if the function is defined with any of the DETERMINISTIC, NO SQL, or READS SQL DATA characteristics.

  • When log_bin_trust_function_creators is OFF and log_bin is ON, the SUPER privilege is also required to execute the following statements:

    • CREATE FUNCTION

    • CREATE TRIGGER

  • Setting log_bin_trust_function_creators to ON removes these requirements around functions characteristics and the SUPER privileges.

  • See Binary Logging of Stored Routines for more information.

  • Command line: --log-bin-trust-function-creators[={0|1}]

  • Scope: Global

  • Dynamic: Yes

  • Data Type: boolean

  • Default Value: OFF

  • Data Type: boolean

  • Default Value: ON

  • Dynamic: No

  • Data Type: boolean

  • Default Value: OFF

  • Data Type: string

  • Default Value: master.info

  • Introduced: (as a system variable, previously just an option)

  • Data Type: bool

  • Default Value: OFF (0)

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 18446744073709547520

  • Range: 4096 to 18446744073709547520

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 1073741824 (1GB)

  • Range: 4096 to 1073741824 (4KB to 1GB)

  • Data Type: numeric

  • Default Value: 18446744073709547520 (64 bit), 4294963200 (32 bit)

  • Range: 4096 to 18446744073709547520

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 18446744073709551615

  • Introduced:

  • Data Type: numeric

  • Default Value: 0

  • Range: 0, or 4096 to 1073741824 (4KB to 1GB)

  • Data Type: numeric

  • Default Value: 0 (no limit)

  • Range: 0 to 18446744073709551615

  • Scope: Global
  • Dynamic: No

  • Data Type: filename

  • Default Value: '' (none)

  • Data Type: string

  • Default Value: None

  • Dynamic: No

  • Dynamic: No

  • Data Type: string

  • Default Value: None

  • Scope: Global

  • Dynamic: No

  • Data Type: string

  • Default Value: relay-log.info

  • Data Type: boolean

  • Default Value: ON

  • Note: In MySQL and in MariaDB before version 10.0.8 this variable was silently changed if you did CHANGE MASTER.

  • Scope: Global

  • Dynamic: Yes

  • Data Type: boolean

  • Default Value: OFF

  • Dynamic: No
  • Data Type: numeric

  • Default Value: 0

  • Range - 32 bit: 0 to 4294967295

  • Range - 64 bit: 0 to 18446744073709547520

  • Data Type: boolean

  • Default Value: ON

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.
  • See Replication Filters for more information.

  • Command line: --replicate-do-db=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.

  • See Replication Filters for more information.

  • Command line: --replicate-do-table=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • Dynamic: Yes
  • Data Type: enumeration

  • Default Value: replicate

  • Valid Values: REPLICATE, FILTER_ON_SLAVE, FILTER_ON_MASTER

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.
  • See Replication Filters for more information.

  • Command line: --replicate-ignore-db=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.

  • See Replication Filters for more information.

  • Command line: --replicate-ignore-table=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • This option only affects statements that involve tables. This option does not affect statements involving the database itself, such as CREATE DATABASE, ALTER DATABASE, and DROP DATABASE.
  • When setting it on the command-line or in a server option group in an option file, the option does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the option multiple times.

  • See Replication Filters for more information.

  • Before , replicate_rewrite_db was not available as a system variable, only as a mariadbd option, and could not be set dynamically. From MariaDB 10.11, it is available as a dynamic system variable

  • Command line: --replicate-rewrite-db=primary_database->replica_database

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • Introduced:

  • Data Type: boolean

  • Default Value: OFF

  • Introduced: (as a system variable, previously just an option)

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.
  • See Replication Filters for more information.

  • Command line: --replicate-wild-do-table=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • When setting it on the command-line or in a server option group in an option file, the system variable does not accept a comma-separated list. If you would like to specify multiple filters, then you need to specify the system variable multiple times.
  • See Replication Filters for more information.

  • Command line: --replicate-wild-ignore-table=name

  • Scope: Global

  • Dynamic: Yes

  • Data Type: string

  • Default Value: '' (empty)

  • Dynamic: No
  • Data Type: string

  • Dynamic: No
  • Data Type: string

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 65535

  • Dynamic: No
  • Data Type: string

  • In and below, the default server_id value is 0. If a replica's server_id value is 0, then all primary's will refuse its connection attempts. If a primary's server_id value is 0, then it will refuse all replica connection attempts.

  • Command line: --server-id =#

  • Scope: Global, Session

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 1

  • Range: 1 to 4294967295

  • Data Type: boolean

  • Default Value: OFF

  • Introduced: (as a system variable, previously just an option)

  • Dynamic: Yes
  • Data Type: boolean

  • Default Value: OFF

  • Dynamic: Yes
  • Data Type: boolean

  • Default Value: OFF

  • Dynamic: Yes
  • Data Type: double

  • Default Value: 31536000.000000

  • Range: 0 to 31536000

  • Introduced:

  • Data Type: boolean

  • Default Value: 0

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 1; 0 on Galera cluster nodes.

  • Range: 0 to 18446744073709551615

  • Introduced:

  • Scope: Global

  • Dynamic: Yes

  • Data Type: enumeration

  • Default Value: IDEMPOTENT

  • Valid Values: IDEMPOTENT, STRICT

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 0

  • Valid Values: 0 to 16383

  • Default Value: IDEMPOTENT (NDB), STRICT (All)

  • Valid Values: IDEMPOTENT, STRICT

  • Data Type: file name

  • Default Value: /tmp

  • Data Type: numeric

  • Default Value: 1073741824

  • Range: 1024 to 1073741824

  • Data Type: numeric

  • Default Value: 0.000000

  • Range: 0 to 31536000

  • Introduced:

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value:

    • 60 (1 minute)

  • Range: 1 to 31536000

  • This system variable is only meaningful when parallel replication is configured (i.e. when slave_parallel_threads > 0).

  • See Parallel Replication: Configuring the Maximum Size of the Parallel Slave Queue for more information.

  • Command line: --slave-parallel-max-queued=#

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 131072

  • Range: 0 to 2147483647

  • aggressive: tries to maximize the parallelism, possibly at the cost of increased conflict rate.

  • minimal: only parallelizes the commit steps of transactions.

  • none disables parallel apply completely.

  • Command line: None

  • Scope: Global

  • Dynamic: Yes

  • Data Type: enum

  • Default Value: optimistic (>= ), conservative (<= )

  • Valid Values: conservative, optimistic, none, aggressive and minimal

  • The replica threads must be stopped in order to change this option's value dynamically.

  • Events that were logged with GTIDs with different gtid_domain_id values can be applied in parallel in an out-of-order manner. Each gtid_domain_id can use the number of threads configured by slave_domain_parallel_threads.

  • Events that were group-committed on the primary can be applied in parallel in an in-order manner, and the specific behavior can be configured by setting slave_parallel_mode.

  • Command line: --slave-parallel-threads=#

  • Scope: Global

  • Dynamic: Yes

  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 16383

  • Data Type: enum

  • Default Value: NO

  • Valid Values: NO, YES, LOGGING, or ENFORCE (>= )

  • Dynamic: No

  • Data Type: string

  • Default Value: OFF

  • Valid Values: [list of error codes], ALL, OFF

  • Data Type: bool

  • Default Value: ON (1)

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 10

  • Range - 32 bit: 0 to 4294967295

  • Range - 64 bit: 0 to 18446744073709547520

  • Dynamic: No

  • Data Type: string

  • Default Value:

    • 1158,1159,1160,1161,1205,1213,1020,1429,2013,12701 (>= , , , , , )

    • 1158,1159,1160,1161,1205,1213,1429,2013,12701 (>= )

  • Valid Values: comma-separated list of error codes

  • Introduced:

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 3600

  • Empty (default) means that the server should give an error and replication should stop if the table definition is different between the primary and replica.

  • Command line: --slave-type-conversions=set

  • Scope: Global

  • Dynamic: Yes

  • Data Type: set

  • Default Value: Empty variable

  • Valid Values: ALL_LOSSY, ALL_NON_LOSSY, empty

  • boolean
  • Default Value: 1

  • Related variables: log_bin

  • Default Value: 0

    Dynamic: Yes
  • Data Type: numeric

  • Default Value: 0

  • Range: 0 to 4294967295

  • Data Type: numeric

  • Default Value: 10000

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 10000

  • Dynamic: Yes
  • Data Type: numeric

  • Default Value: 10000

  • Range: 0 to 4294967295

  • Full list of MariaDB options, system and status variables
    AUTO_INCREMENT
    replication
    AUTO_INCREMENT
    replication
    auto_increment_increment
    AUTO_INCREMENT#Replication
    annotate_rows_events
    binary log
    binlog_stmt_cache_size
    binlog_cache_disk_use
    binlog_cache_use
    server status variables
    binary log
    group commit for the binary log
    conservative mode of in-order parallel replication
    group commit for the binary log
    binary log
    binlog_commit_wait_usec
    conservative mode of in-order parallel replication
    binlog_group_commit_trigger_count
    InnoDB
    conservative mode of in-order parallel replication
    slave_parallel_threads
    group commit for the binary log
    conservative mode of in-order parallel replication
    group commit for the binary log
    binary log
    binlog_group_commit_trigger_timeout
    binlog_commit_wait_count
    Replication
    binlog_format
    replication primary
    binary log
    binary log
    statement-based logging
    Statement-Based Logging
    expire_logs_days
    binary log
    relay log
    replication
    Binary Log Formats
    Binlog indexing
    Binlog indexing
    Binlog indexing
    replication primary
    binary log
    binary log
    statement-based logging
    Statement-Based Logging
    binary log
    row-based
    replication
    statement-based replication
    max_binlog_total_size
    binary log
    binlog_cache_size
    binlog_stmt_cache_disk_use
    binlog_stmt_cache_use
    server status variables
    binary logging formats
    binary log
    multi-source replication
    binary logs
    relay logs
    Data at Rest Encryption
    Encrypting Binary Logs
    binary log
    replication
    PURGE BINARY LOGS
    MariaDB 10.6.0
    binlog_expire_logs_seconds
    init_connect
    START SLAVE
    binary logging
    option
    --log-basename
    replication
    data directory
    Compressing Events to Reduce Size of the Binary Log
    Compressing Events to Reduce Size of the Binary Log
    --log-basename
    replication
    binary log
    log_bin
    CREATE FUNCTION
    ALTER FUNCTION
    slow log
    replication
    binlog checksums
    max_binlog_stmt_cache_size
    binlog_cache_size
    binary log
    relay logs
    max_relay_log_size
    max_binlog_cache_size
    binlog_stmt_cache_size
    binary logs
    slave_connections_needed_for_purge
    relay log
    max_binlog_size
    multi-source replication
    replica
    Relay log
    --log-basename
    --log-basename
    relay-log
    relay log
    --log-basename
    --log-basename
    relay log
    CHANGE MASTER
    replica's SQL thread
    relay log
    CHANGE MASTER TO: Option Persistence
    relay logs
    relay logs
    relay_log_purge
    relay logs
    annotate_rows_events
    log_slave_updates
    replica
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    replica
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    replicate
    Selectively skipping replication of binlog events
    replica
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    replica
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    replica
    binary log
    USE
    statement-based logging
    Statement-Based Logging
    --log-slave-updates
    replica
    LIKE
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    replica
    LIKE
    statement-based logging
    Statement-Based Logging
    SET GLOBAL
    SHOW SLAVE HOSTS
    SHOW SLAVE HOSTS
    replication
    replicating
    SHOW SLAVE HOSTS
    replication
    MariaDB replication
    binary log
    MariaDB replication
    MariaDB replication
    SHOW REPLICA HOSTS
    slave_parallel_mode
    parallel replication
    binary log
    replicated
    Selectively skipping replication of binlog events
    binary log
    max_binlog_total_size
    binlog_expire_logs_seconds
    expire_logs_days
    replication
    CREATE TABLE
    CREATE OR REPLACE TABLE
    DROP TABLE
    replication
    slave_parallel_threads
    Parallel Replication
    replication
    replicating
    LOAD DATA INFILE
    tmpdir
    max_allowed_packet
    replication
    CHANGE MASTER
    master-retry-count
    parallel_replication
    SQL thread
    worker thread
    slave_parallel_max_queued
    slave_parallel_threads
    parallel replication
    optimistic mode
    conservative mode
    parallel replication
    worker threads
    binary log
    worker threads
    binary log
    SQL thread
    slave_parallel_threads
    Running triggers on the slave for Row-based events
    replication
    error codes
    slave_skipped_errors
    binlog checksums
    relay log
    replication
    innodb_lock_wait_timeout
    replication
    error numbers
    Spider
    slave_transaction_retry_errors
    row-based
    replication
    binary log
    log_bin
    SET GLOBAL sql_slave_skip_counter
    replication
    relay log
    replication
    MariaDB Galera Cluster
    Using MariaDB Replication with MariaDB Galera Cluster: Setting server_id on Cluster Nodes
    DROP TRIGGER
    MariaDB 5.3
    MariaDB versus MySQL - Compatibility: Replication Compatibility
    Replication Compatibility Between MariaDB and MySQL
    MariaDB 10.4
    MariaDB 10.5
    MariaDB 10.4
    MariaDB 10.5
    MariaDB 5.3
    MariaDB 5.3
    What is MariaDB 5.3
    MariaDB 10.2.3
    MariaDB 10.2.3
    What is MariaDB 5.3
    MariaDB 10.5.1
    MariaDB 10.5.2
    MariaDB 10.5.1
    MariaDB 10.5.2
    MariaDB 10.2.3
    MariaDB 5.3
    MariaDB 5.3
    MariaDB 5.2
    MariaDB 5.3
    MariaDB 5.3
    MariaDB 5.2
    MariaDB 10.4
    MariaDB 10.4
    MariaDB 10.3
    requires more configuration
    Replication from MySQL 8 to MariaDB
    MariaDB 10.5.2
    MariaDB 10.5.2
    MariaDB 5.5
    MariaDB 10.0
    MariaDB 10.0
    MariaDB 10.0
    MariaDB 10.0
    MariaDB 10.0
    MariaDB 10.5.2
    MariaDB 10.11
    MariaDB 10.3
    MariaDB 10.6.19
    MariaDB 10.11.9
    MariaDB 11.1.6
    MariaDB 11.2.5
    MariaDB 11.4.3
    MariaDB 11.5.2
    MariaDB 10.1.2
    MariaDB 10.3.3
    MariaDB 10.3.3
    MariaDB 10.3.3
    MariaDB 10.1.13
    MariaDB 10.0.13
    MariaDB 10.0.11
    MariaDB 5.5
    MariaDB 11.2.0
    MariaDB 11.2.0
    MariaDB 10.11
    MariaDB 10.11
    MariaDB 10.0.5
    MariaDB 10.5.1
    MariaDB 10.5.0
    MariaDB 10.0.2
    MariaDB 10.3.1
    MariaDB 10.1.4
    MariaDB 10.0.2
    MariaDB 11.3
    MariaDB 10.4.1
    MariaDB 10.1.5
    MariaDB 10.0.18
    MariaDB 10.1.4
    MariaDB 10.1.5
    MariaDB 11.2.0
    MariaDB 10.6.1
    MariaDB 10.2.3
    MariaDB 10.0.22
    MariaDB 11.2.0
    MariaDB 11.7
    MariaDB 11.2.0
    MariaDB 11.4
    MariaDB 10.6.1
    MariaDB 10.6.1
    MariaDB 10.1.13
    MariaDB 10.1.7
    MariaDB 10.1.7
    MariaDB 10.8.1
    MariaDB 11.2.0
    MariaDB 10.6.1
    MariaDB 11.4
    MariaDB 11.4
    MariaDB 11.4
    MariaDB 11.2.0
    MariaDB 11.7
    MariaDB 11.4
    MariaDB 11.7
    MariaDB 11.2.0
    MariaDB 11.4
    MariaDB 11.3
    MariaDB 11.4
    MariaDB 10.5.0
    MariaDB 12.0
    MariaDB 10.6.1
    MariaDB 10.6.0
    MariaDB 12.0
    MariaDB 11.4
    MariaDB 10.11
    MariaDB 10.11.0
    MariaDB 12.0
    MariaDB 10.2.1
    MariaDB 12.0
    MariaDB 11.7
    MariaDB 11.4
    MariaDB 10.10
    MariaDB 10.5.1
    MariaDB 10.5.0
    MariaDB 10.5.2
    MariaDB 10.6.18
    MariaDB 10.11.8
    MariaDB 11.0.6
    MariaDB 11.1.5
    MariaDB 11.2.4
    MariaDB 11.4.2
    MariaDB 10.4.5
    MariaDB 10.3.3