环境 :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; 此时将会跳过此事务,继续复制主库。但是主库一旦有对此条或者多条数据的修改,从库的复制将会再次断开

Mysql error 1317导致从库复制断开的更多相关文章

  1. MySQL锁(二)表锁:为什么给小表加字段会导致整个库挂掉?

    概述 表级锁是MySQL中锁定粒度最大的一种锁,表示对当前操作的整张表加锁,它实现简单,资源消耗较少,被大部分MySQL引擎支持.最常使用的MYISAM与INNODB都支持表级锁定.表级锁定分为表共享 ...

  2. mysql 5.7主从库复制设置

    先要修改配置文件,重启mysql服务 log-bin= mysql-binlog # 打开二进制日志 ,最好放在不同的硬盘上,减小 IO 消耗 expire_logs_day= # 设置二进制日志保存 ...

  3. 基于mysql创建库的报错解决小记mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database

    mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database异常处理 1.找到find / -name my. ...

  4. 我的MYSQL学习心得(十七) 复制

    我的MYSQL学习心得(十七) 复制 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据 ...

  5. MYSQL ERROR CODE 错误编号的意义

    mysql error code(备忘) 转1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件 ...

  6. MySQL/MariaDB数据库的主从级联复制

      MySQL/MariaDB数据库的主从级联复制 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.主从复制类型概述 1>.主从复制 博主推荐阅读: https://ww ...

  7. mysql传统主从、双主复制+keepalived配置步骤

    mysql主从.主主复制(双主复制)配置步骤 一:MySQL复制: MySQL复制简介: 将master服务器中主数据库的ddl和dml操作通过二进制日志传到slaves服务器上,然后在master服 ...

  8. mysql下批量清空某个库下的所有表(库不要删除,保留空库)

    总所周知,mysql下要想删除某个库下的某张表,只需要切换到该库下,执行语句"drop table tablename"即可删除!但若是该库下有成百上千张表,要是再这样一次次执行d ...

  9. 详解MySQL主从复制实战 - 基于GTID的复制

    基于GTID的复制 简介 基于GTID的复制是MySQL 5.6后新增的复制方式. GTID (global transaction identifier) 即全局事务ID, 保证了在每个在主库上提交 ...

随机推荐

  1. 七、Sql Server 基础培训《进度7-笛卡尔积(知识点+实际操作)》

    知识点: 1.笛卡尔介绍 笛卡尔,近代法国著名哲学家.物理学家.数学家.神学家. 主要成就概述 笛卡尔在科学上的贡献是多方面的.笛卡尔不仅在哲学领域里开辟了一条新的道路,同时笛卡尔又是一勇于探索的科学 ...

  2. [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串

    Given a string, find the length of the longest substring without repeating characters. Example 1: In ...

  3. jquery面试(2)

    DOM操作——怎样添加.移除.移动.复制.创建和查找节点? (1)创建新节点 createDocumentFragment() //创建一个DOM片段 createElement() //创建一个具体 ...

  4. 关于 python中的转义字符

    "abc\n" 前面加 r,表示原生输出,不转义.实际上是用 \代替 \\,其实是已经转义过了,并不是不转义. 看这个例子: print(r"abc \n") ...

  5. 关于vue-cli创建项目(小白)

    vue-cli,都说是vue脚手架,一般cli是命令行的意思,一看就知道与node有关,其实脚手架是建筑工用的工具,给工人踩在上面干活的,这里借用它的意思,我觉得应该叫vue平台工具大家更容易懂,毕竟 ...

  6. win 10安装Linux虚拟机教程

    1.首先下载虚拟机 用的是VMware 官方下载地址:https://my.vmware.com/en/web/vmware/free#desktop_end_user_computing/vmwar ...

  7. Python学习之旅(三十)

    Python基础知识(29):virtualenv virtualenv:用来为一个应用创建一套隔离的Python运行环境 比如,现有两个Python项目,一个是Python2.7的一个是Python ...

  8. VM装mac10.9教程+报错信息解决办法

    VM装mac10.9教程+报错信息解决办法 教程1: 教你在Vmware 10下安装苹果Mac10.9系统 地址:http://tieba.baidu.com/p/2847457021 教程2: VM ...

  9. 学习 ASP.NET Core 2.1:集成测试中使用 WebApplicationFactory

    WebApplicationFactory 是 ASP.NET Core 2.1 新特性 MVC functional test infrastructure 中带来的新东东,它封装了 TestSer ...

  10. Emmet.vim 教程

    Emmet.vim 教程 May 5, 2012 目录 1 下载 Emmet.vim 2 安装 Emmet.vim 3 使用 Emmet.vim 4 余话 Emmet 项目原先叫 Zen Coding ...