Today, all MySQL slave replication from the server is abnormally interrupted, landed on one of the platform to execute show slave status\g, found the following error:
--
Last_error:error ' Operation DROP USER failed for ' guest ' @ ' localhost ' on query. Default database: ' Work '. Query: ' Drop user ' guest ' @ ' localhost '
--
In other words, this is caused by the command drop user ' guest ' @ ' localhost ', which we usually only do on master, and that this action should only affect the "MySQL" System database. This kind of operation has been done many times before, but why this time alone will be a problem?
After some investigation, we finally found the root of the problem, that is,
"Binlog-do-db, Binlog-ignore-db, replicate-do-db, replicate-ignore-db" This kind of parameter, is not imagined reliable!
Usually, we assume that as long as the above parameters are set, the master-slave copy of MySQL will only take effect on the database we set up. But in fact, MySQL is not based on content to judge, but very silly based on you do the "use of work" or in the initial connection specified by the database to judge.
And this time, before we execute the drop user, because we need to select some data from the "work" database, we have to go into the work database, and we all know that there is no need to go to the "MySQL" system database when executing the drop user. So we executed the drop user directly, but because MySQL's judgment was executed after the use of work, it was considered that the operation of the "working" database was synchronized, and there were no [email protected] users from the service. The result is an error that causes a master-slave replication interrupt.
Therefore, in a MySQL server environment with a master-slave replication architecture, we try to avoid such cross-library operations to ensure that the command is executed after the correct use dbname is executed.
The recovery scenario for this type of failure is simple enough to skip this SQL.
--
Stop slave;
Set global sql_slave_skip_counter=1;
Start slave;
Show Slave Status\g
--
Resources:
http://www.mysqlperformanceblog.com/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous/
A master-slave replication interrupt caused by MySQL cross-Library operations at a time