作者:付祥
现居珠海,主要负责 Oracle、MySQL、mongoDB 和 Redis 维护工作。
本文来源:原创投稿
*爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。
1.故障现象
一套运行快两年的MGR三节点多主环境(5.7.25),在节点1成功导入一批数据后,开发反馈程序修改这批数据报错,报错信息如下:
update match_equip set name = ?, type = ?, equips = ?,score = ? where id = ? and
person_id = ?
Received #3101 error from MySQL server: "Plugin instructed the server to rollback
the current transaction."
1.1.尝试故障恢复操作1
经过初步分析,发现导入的这批数据,在导入节点1可以更新,在其他节点更新失败,怀疑1节点有问题,本着快速恢复故障原则,询问开发得知1节点可以重启,于是对其进行重启,重启后不能加入组复制,看来重启大法也不好使,报错信息如下:
2021-05-27T07:37:53.290267Z 0 [ERROR] Plugin group_replication reported: 'This
member has more executed transactions than those present in the group. Local
transactions: 91f9d301-c234-11e9-
b15f-fa163e13423a:1-156817757:156843131-157503127:158192163-158412212,
a71d98a2-c234-11e9-b6db-fa163e3407f8:1-92,
eba21052-c250-11e9-b0d0-fa163e134234:1-3 > Group transactions: 91f9d301-c234-
11e9-b15f-fa163e13423a:1-156817825:156843131-157503172:158192163-158412212,
eba21052-c250-11e9-b0d0-fa163e134234:1-3'
2021-05-27T07:37:53.290348Z 0 [ERROR] Plugin group_replication reported: 'The
member contains transactions not present in the group. The member will now exit
the group.'
Local transactions:
Local transactions:
91f9d301-c234-11e9-b15f-fa163e13423a:1-156817757:156843131-157503127:158192163-
158412212,
a71d98a2-c234-11e9-b6db-fa163e3407f8:1-92,
eba21052-c250-11e9-b0d0-fa163e134234:1-3
Group transactions:
Group transactions:
91f9d301-c234-11e9-b15f-fa163e13423a:1-156817825:156843131-157503172:158192163-
158412212,
eba21052-c250-11e9-b0d0-fa163e134234:1-3
经过比较,本地节点已执行的gitd集合中 a71d98a2-c234-11e9-b6db-fa163e3407f8:1-92 gtid 并不在Group transactions中,即 Local transactions 不是 Group transactions 子集,无法通过验证,加入集群失败。
1.2. 尝试故障恢复操作2
通过正常节点物理备份还原的方式加入集群,还是报错:
2021-05-27T08:35:01.331704Z 13 [ERROR] Plugin group_replication reported: 'The
certification information could not be set in this server: 'Certification
information is too large for transmission.''
2021-05-27T08:35:01.331752Z 13 [ERROR] Plugin group_replication reported: 'Error
when processing Certification information in the Recovery process'
2021-05-27T08:35:01.331762Z 13 [ERROR] Plugin group_replication reported: 'Fatal
error during the Recovery process of Group Replication. The server will leave the
group.
由于传输的集群冲突校验信息太大而加入集群失败:
Certification information is too large for transmission
查看当前集群冲突检测信息:
root@3306 performance_schema> select COUNT_TRANSACTIONS_ROWS_VALIDATING from
performance_schema.replication_group_member_stats;
+------------------------------------+
| COUNT_TRANSACTIONS_ROWS_VALIDATING |
+------------------------------------+
| 11239426 |
+------------------------------------+
1 row in set (0.00 sec)
当前冲突检测信息有1千多万条记录,正是由于这个信息太大导致加入集群失败。事情到这里,估计有人会认为碰上了 mysql bug ,实则不然,要解决这个问题,还得从 mgr 事务冲突检测机制说起。
2.故障分析与复现
2.1.事务认证机制
参考文章:https://zhuanlan.zhihu.com/p/41175310
MGR 事务认证模块用于决定进入MGR的事务是继续提交还是需要被回滚,实现该功能的依据是判断冲突检测数据库(certification_info)中被该事务更新的各个主键的 gtid_set 是否为事务的快照版本 snapshot_version 的子集,若是则提交,否则进行回滚。

对于可继续提交的事务,为其分配

本文详细分析了一起MySQL 5.7.25 MGR(多主模式)环境中遇到的故障,包括导入数据后更新报错、节点重启无法加入集群等问题。故障原因在于节点间的事务认证机制,其中一个节点存在独立的本地事务,导致冲突检测数据库certification_info记录积累过多,无法清理。在故障恢复过程中,通过重启节点、重置主从关系、调整参数等方式解决了问题。文章强调了在搭建MGR时必须确保环境干净,避免本地事务,并对遇到类似问题提供了处理思路。
最低0.47元/天 解锁文章
866

被折叠的 条评论
为什么被折叠?



