Skip to content

RandomQueryGeneratorReplication

philip-stoev edited this page Jul 17, 2012 · 1 revision

Category:RandomQueryGenerator

Using the RQG to test MySQL replication

To test replication, start the test as follows:

 $ perl runall.pl \
   --rpl_mode=row \
   --basedir=/path/to/mysql-dir \
   --grammar=conf/replication_simple.yy    

This will start a master and a slave, and, upon the termination of the test (or hitting Ctrl+C), their contents will be dumped and compared. Any differences will be reported.

You can also use --rpl_mode=default to start a replication setup without explicitly using SET BINLOG_FORMAT to force a particular logging format.

conf/replication.yy is a grammar designed to exercise all binary log event types. It includes LOAD DATA, RAND(), LAST_INSERT_ID(), log rotation, along with on-the-fly switching between statement-based replication and the initial mode specified with --rpl_mode= .

conf/replication_simple.yy is a simpler grammar that only includes basic INSERT/UPDATE/DELETE queries.

conf/replication_single_engine.zz can be used to create a set of tables using the default storage engine.

conf/replication_innodb_myisam.zz creates both MyISAM and InnoDB tables, facilitating testing where both engines should be exercised.

On every query, the script will also check the status of the slave with SHOW SLAVE STATUS and will report and error if the slave thread has stopped. However, since the slave may be lagging behind the master, the error may be reported much later than the actual query that caused it. To rectify that, use the ReplicationWaitForSlave Validator. This will cause MASTER_POS_WAIT() to be used continously so that the slave will never be far behind. This way replication errors will be reported much closer to their actual origin.

However, it is still possible for a replication error to be reported on a valid query only because the slave has been corrupted by some previous query. To catch such cases as soon as possible, use the DatabaseComparator Validator. It will cause the slave and the master to be compared with mysqldump after each query, allowing the error to be reported as soon as they diverge. This option however will slow your test down and will only make sense with --threads=1.