How can I skip all errors on an RDS replica instance? How can I skip all errors on an RDS replica instance? mysql mysql

How can I skip all errors on an RDS replica instance?


I solved it by creating a mysql event scheduler like this :

CREATE EVENT repl_error_skipper ON SCHEDULE EVERY 15 MINUTECOMMENT 'Calling rds_skip_repl_error to skip replication error'DoCALL mysql.rds_skip_repl_error;/*also you can add other logic */

To set other global variables you can find and set those (if available for changing) in rds parameter group (you will have to create new parameter group and set the variable values).


As mentioned, this command only skips one replication error. I wrote a PHP script to loop through this and ran it once a minute via cron job (my replica was log jammed with a series of thousands of bad queries than went through on the main DB)

for($i = 1; $i <= 30; $i++) {        $db = new mysqli('someserver.rds.amazonaws.com', 'root', 'password');        $res = $db->query('CALL mysql.rds_skip_repl_error;');        if(!$res) {                //echo 'Query failed: ' . $db->error . "\n";                return;        }        //var_dump($res->fetch_assoc());        $db->close();        sleep(1);}

You'll need to tinker with this some (not every server would tolerate only one second between calls and 30 calls per minute), but it does work (albeit in a brute force manner). You must create a new DB connection every time to run this. The loop opens, runs and then closes the connection.