Versions

VersionStatusIntroduced
1.0StableMariaDB 10.1.13
1.0Gamma

Setup

Regular MariaDB replication is asynchronous. MariaDB, since MariaDB 5.5, has included the Semisynchronous replication plugin (strictly speaking two plugins, one for the master and one for the slave). To make the functionality available. regular replication should be set up, and then the semisynchronous plugins installed, on both the master and the slave:

INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';

INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';

Correct installation can be checked by seeing if the plugins are listed after issuing the SHOW PLUGINS statement.

After installation, semisynchronous replication is enabled by setting the rpl_semi_sync_master_enabled and rpl_semi_sync_slave_enabled variables to ON.

In semisynchronous replication, only after the events have been written to the relay log and flushed does the slave acknowledge receipt of a transaction's events. If the slave does not acknowledge the transaction before a certain amount of time has passed (configurable with the rpl_semi_sync_master_timeout variable), a timeout occurs and the master switches to asynchronous replication. When at least one semisynchronous slave catches up, semisynchronous replication is resumed.

If semisynchronous replication is enabled on a slave at runtime, the slave I/O thread will need to be started (or restarted) to enable the slave to register as a semisynchronous slave when it connects to the master:

STOP SLAVE IO_THREAD;
START SLAVE IO_THREAD;

If this is not done, and the slave thread is already running, it will continue to use asynchronous replication.

MariaDB starting with 10.1.3

Enhanced semisync replication was added in MariaDB 10.1.3 (MDEV-162)

The following system variables are added when either the master or slave Semisynchronous replication plugin is installed:

System variables

rpl_semi_sync_master_enabled

  • Description: Set to ON to enable semi-synchronous replication master. Disabled by default.
  • Commandline: --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 master. If this timeout is exceeded in waiting on a commit for acknowledgement from a slave, the master will revert to asynchronous replication, setting the Rpl_semi_sync_master_status status variable to OFF as it does so.
  • Commandline: --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.
  • Commandline: --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 set to ON, the default, the slave count (recorded by Rpl_semi_sync_master_clients) may drop to zero, and the master will still wait for the timeout period. If set to OFF, the master will revert to asynchronous replication as soon as the slave count drops to zero.
  • Commandline: --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, the default), or after having committed in storage engine (AFTER_COMMIT). With AFTER_SYNC, all clients see the same data on the master at the same time; after acknowledgement by the slave and after being committed to the storage engine on the master. If the master crashes, because all transactions committed on the master have been replicated to the slave, so failover is lossless. With AFTER_COMMIT, the return status is received by the transaction only after the server commits to the storage engine and receives slave acknowledgement. Other clients may see the committed transaction before the committing client, and if the master crashes, it is possible that clients will see data loss relative to what they saw on the master.
  • Commandline: --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_enabled

  • Description: Set to ON to enable semi-synchronous replication slave. Disabled by default.
  • Commandline: --rpl-semi-sync-slave-enabled[={0|1}]
  • Scope: Global
  • Dynamic: Yes
  • Data Type: boolean
  • Default Value: OFF

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.
  • Commandline: --rpl-semi-sync-slave-trace_level[=#]
  • Scope: Global
  • Dynamic: Yes
  • Data Type: numeric
  • Default Value: 32
  • Range: 0 to 18446744073709551615

Status Variables

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

Comments

Comments loading...