Mysql – Running Triggers on Slave with Row-based Events in MySQL >=5.6

mariadbMySQLmysql-5.6

We would like to have a setup where a slave has triggers that are not present on the master for the purpose of updating some summary tables or run a specific udfs.sys

If one uses statement-based replication, they can just create the required triggers on the slave. The slave will run the statements from the binary log, which will cause the triggers to be invoked. With (the suggested) row-based, quote:

If under row-based replication the slave applied the triggers as well
as the row changes caused by them, the changes would in effect be
applied twice on the slave, leading to different data on the master
and the slave.

https://dev.mysql.com/doc/refman/5.6/en/replication-features-triggers.html

Is there a way to run triggers on slave only with row-based replication, similar to what mariaDB have?

Best Answer

Perhaps instead, you require a Stored Procedure on your slave that you can run from a cron job mysql -e "call sp_udfs" to do the processing across the tables to alter that data. Events disable by default in a slave You could do a lot of work with that approach. This way you can control its behaviour much better than triggers. Other benefit, you can run any form of replication you wish, row, statement or mixed