bug描述:当使用revoke,grant命令收回,授予权限出错时(语法错误除外),会导致主从同步异常终止。如:
mysql> revoke select on *.* from aaa;
ERROR 1141 (42000): There is no such grant defined for user ‘aaa‘ on host ‘%‘ 该用户没有该权限却执行了回收该权限
mysql> GRANT FILE ON test.* TO test@127.0.0.1;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES 错误授权等
影响版本:mysql 5.6~5.6.13
场景重现:
master:
mysql> insert into a values(1);
Query OK, 1 row affected (0.00 sec)
mysql> GRANT FILE ON test.* TO test@127.0.0.1;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> insert into a values(2);
Query OK, 1 row affected (0.00 sec)
mysql> insert into a values(3);
Query OK, 1 row affected (0.00 sec)
slave:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.0.44
Master_User: rpladmin
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: online044-bin.000013
Read_Master_Log_Pos: 307
Relay_Log_File: online045-relay-bin.000028
Relay_Log_Pos: 474
Relay_Master_Log_File: online044-bin.000012
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1590
Last_Error: The incident LOST_EVENTS occured on the master. Message: error writing to the binary log
Skip_Counter: 0
Exec_Master_Log_Pos: 307
Relay_Log_Space: 1634
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1590
Last_SQL_Error: The incident LOST_EVENTS occured on the master. Message: error writing to the binary log
Replicate_Ignore_Server_Ids:
Master_Server_Id: 17216044
Master_UUID: cad43e8b-97b0-11e4-a557-00505681293d
Master_Info_File: /data/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 150109 14:07:55
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
解决方法:
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> set global sql_slave_skip_counter=1;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
mysql> select * from a;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.0.44
Master_User: rpladmin
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: online044-bin.000012
Read_Master_Log_Pos: 120
Relay_Log_File: online045-relay-bin.000028
Relay_Log_Pos: 287
Relay_Master_Log_File: online044-bin.000012
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 120
Relay_Log_Space: 631
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 17216044
Master_UUID: cad43e8b-97b0-11e4-a557-00505681293d
Master_Info_File: /data/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
官方bug参考地址:http://bugs.mysql.com/bug.php?id=68892
BUG:mysql 5.6 Invalid use of GRANT/REVOKE command breaks replication
原文地址:http://blog.csdn.net/dbaheng/article/details/42554405