Mysql error 1317导致从库复制断开

环境 :Percona Server for MySQL 5.5.18

1. 报错日志:

171212 19:59:58 [ERROR] Slave SQL: Query partially completed on the master (error on master: 1317) and was aborted. There is a chance that your master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; . Query: 'SAVEPOINT `ZZG`', Error_code: 1317
171212 19:59:58 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000052' position 6786

2. 重现

Terminal A

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into y select * from x limit 1;
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> savepoint ZZG;
Query OK, 0 rows affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

Terminal B

在 Terminal A 执行到insert 的时候,执行 kill query,去模拟终止 Terminal A 的insert,此时,Terminal A 继续执行以上操作,直到commit 结束。

解析 Terminal A 的binlog

mysqlbinlog mysql-bin.000052 --base64-output=decode-rows -vv |less

得到以下结果

#171212 20:01:22 server id 1  end_log_pos 7929  Write_rows: table id 62 flags: STMT_END_F
### INSERT INTO test.y
### SET
###   @1='def' /* VARSTRING(1536) meta=1536 nullable=0 is_null=0 */
###   @2='information_schema' /* VARSTRING(192) meta=192 nullable=0 is_null=0 */
###   @3='CHARACTER_SETS' /* VARSTRING(192) meta=192 nullable=0 is_null=0 */
###   @4='SYSTEM VIEW' /* VARSTRING(192) meta=192 nullable=0 is_null=0 */
###   @5='MEMORY' /* VARSTRING(192) meta=192 nullable=1 is_null=0 */
###   @6=10 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @7='Fixed' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */
###   @8=NULL /* VARSTRING(30) meta=0 nullable=1 is_null=1 */
###   @9=384 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @10=0 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @11=8388480 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @12=0 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @13=0 /* LONGINT meta=0 nullable=1 is_null=0 */
###   @14=NULL /* LONGINT meta=0 nullable=1 is_null=1 */
###   @15=2017-12-12 18:54:45 /* DATETIME meta=0 nullable=1 is_null=0 */
###   @16=NULL /* DATETIME meta=0 nullable=1 is_null=1 */
###   @17=NULL /* DATETIME meta=0 nullable=1 is_null=1 */
###   @18='utf8_general_ci' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
###   @19=NULL /* VARSTRING(96) meta=0 nullable=1 is_null=1 */
###   @20='max_rows=21845' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
###   @21='' /* VARSTRING(6144) meta=6144 nullable=0 is_null=0 */
# at 7929
#171212 20:01:38 server id 1  end_log_pos 8007  Query   thread_id=3575  exec_time=0     error_code=1317
SET TIMESTAMP=1513080098/*!*/;
SAVEPOINT `ZZG`
/*!*/;
# at 8007
#171212 20:01:45 server id 1  end_log_pos 8034  Xid = 10115
COMMIT/*!*/;
DELIMITER ;
# End of log file

此 error_code=1317 在mysql Master的日志中是不体现的,但是直接导致了从库的复制断开,报错如下

171212 19:59:58 [ERROR] Slave SQL: Query partially completed on the master (error on master: 1317) and was aborted. There is a chance that your master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; . Query: 'SAVEPOINT `ZZG`', Error_code: 1317
171212 19:59:58 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000052' position 6786

此时主库是不影响的,主库的insert 正常提交,从库却没有接收到这个insert,如果此时,在从库上执行报错中提示的 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; 此时将会跳过此事务,继续复制主库。但是主库一旦有对此条或者多条数据的修改,从库的复制将会再次断开

posted @ 2017-12-12 20:55  Coye  阅读(750)  评论(0编辑  收藏  举报