Online GTID deployment

Percona Server now supports Online GTID deployment. This enables GTID to be deployed on existing replication setups without making the master read-only and stopping all the slaves. This feature was ported from the Facebook branch. Before this feature was implemented deploying the GTID replication on already existing replication setups required making a master read_only, shutting down all MySQL instances in the replica set simultaneously at the same position, enabling the gtid_mode variable in my.cnf, and then starting all of the instances. NOTE: This feature does not provide means to disable GTIDs online. Disabling GTIDs online is available in Percona Server 5.7.

With gtid_deployment_step enabled, a host cannot generate GTID values on its own, but if GTID logged events are received through replication stream from master, they will be logged.

Performing the online GTID deployment

The online GTID deployment procedure can be done with the following steps:

  1. replicas: gtid_mode = ON and gtid_deployment_step = ON

    master: gtid_mode = OFF and gtid_deployment_step = OFF

On each replica, one at a time, restart the MySQL server to enable gtid_mode and gtid_deployment_step. Afterward, we are in a state where every replica has gtid_mode set to ON and gtid_deployment_step set to ON, but the master still has gtid_mode set to OFF and gtid_deployment_step set to OFF. NOTE: in order to successfully restart the slaves enforce-gtid-consistency needs to be enabled as well.

  1. new master: gtid_mode = ON and gtid_deployment_step = OFF

    rest of the replicas: gtid_mode = ON and gtid_deployment_step = ON

    old master: gtid_mode = OFF and gtid_deployment_step = OFF

Perform a master promotion as normal, i.e. set the gtid_mode to ON and gtid_deployment_step to OFF, re-pointing the replicas and original master to the new master. The original master’s replication will intentionally break when started, since it still has the variable gtid_mode set to OFF and gtid_deployment_step to OFF.

  1. new master: gtid_mode = ON and gtid_deployment_step = OFF

    rest of the replicas: gtid_mode = ON

    old master: gtid_mode = ON

Restart the original master to enable gtid_mode. It will now be able to replicate from the new master, and the entire replica set now has gtid_mode set to ON. You can now set the gtid_deployment_step to OFF.

Version Specific Information

System Variables

variable gtid_deployment_step
Version Info:
Command Line:

Yes

Config File:

Yes

Scope:

Global

Dynamic:

Yes

Default Value:

OFF

When this variable is enabled, a host cannot generate GTIDs on its own, but if GTID logged events are received through replication stream from the master, they will be logged.

The conditions for dynamic switching the gtid_deployment_step off are the same as for read_only variable:

  1. If you attempt to enable gtid_deployment_step while you have any explicit locks (acquired with LOCK TABLES) or have a pending transaction, an error occurs.
  2. If you attempt to enable gtid_deployment_step while other clients hold explicit table locks or have pending transactions, the attempt blocks until the locks are released and the transactions end. While the attempt to enable gtid_deployment_step is pending, requests by other clients for table locks or to begin transactions also block until gtid_deployment_step has been set.