GreatSQL社区

搜索

[已解决] 长事务导致MySQL MGR集群异常

256 2 2024-1-11 17:08
数据库版本:MySQL社区版 8.0.26
MGR相关参数:
group_replication_communication_max_message_size =10485760
group_replication_compression_threshold=1000000
group_replication_member_expel_timeout=5
group_replication_single_primary_mode=ON
group_replication_transaction_size_limit=750000000

背景:MySQL MGR 3节点集群,单主模式,存在需要使用insert into  table select  复制数据的需求。
模拟SQL如下
insert into t1(c1,c2,c3,c4,c5,c6,c7) select c1,c2,c3,c4,c5,c6,c7 from t2

表t2 大小约为500MB,索引大小约为300MB。
MySQL error 日志如下
2024-01-05T11:18:02.522297+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address 192.168.1.10:7778 has become unreachable.'
2024-01-05T11:18:03.897471+08:00 0 [Warning] [MY-011494] [Repl] Plugin group_replication reported: 'Member with address 192.168.1.10:7778 is reachable again.'
2024-01-05T11:18:11.493942+08:00 0 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Shutting down an outgoing connection. This happens because something might be wrong on a bi-directional connection to node 192.168.1.10:17778. Please check the connection status to this member'
2024-01-05T11:18:50.316212+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address 192.168.1.10:7778 has become unreachable.'
2024-01-05T11:18:51.331608+08:00 0 [Warning] [MY-011494] [Repl] Plugin group_replication reported: 'Member with address 192.168.1.10:7778 is reachableagain.'
2024-01-05T11:19:01.280893+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address 192.168.1.11:7778 has become unreachable.'

通过 select * from performance_schema.replication_group_members 查看所有成员的member_state都为online。但此时其他表的数据无法写入。
通过 mysql client 执行kill 命令,操作后,事务长时间处理 killed的状态,但无法真正的结束,此时集群状态查询,原主节点为 unreachable,其他节点为online。无法重新选举出主节点。通过 kill -9 在服务器层面上强制kill 主节点,观察两个从节点的状态,观察时间超过2个小时,依旧无法恢复正常。

问题如下
1.长事务是如何影响MySQL MGR的集群的通信?
2.官方文档写数据包应该会按照10MB大小分片的发送,为什么集群通信还是受到的影响?
3.主节点kill掉后的时间里,两个从节点在做什么?为什么无法选举?

全部回复(2)
yejr 2024-1-11 17:19:31
1. 尝试调大 group_replication_transaction_size_limit=750000000 值,看起来应该是最大事上限导致失败,这个最大支持2G,可以先跳到2G上限试试。
2. MGR多节点间通信及大事务的影响可参考文档: https://gitee.com/GreatSQL/Great ... deep-dive-mgr-11.md
3. 大事务导致MGR通信失败,也会导致节点间通信异常,在频繁断开时,会影响选主。
4. 建议升级到GreatSQL 8.0.32-25最新版本,GreatSQL对MGR做了相当多的底层改造和完善,运行MGR会更稳定可靠,详见: https://greatsql.cn/docs/8032-25 ... enhance/5-2-ha.html
yejr 2024-1-11 17:26:29
通过 select * from performance_schema.replication_group_members 查看所有成员的member_state都为online。但此时其他表的数据无法写入。
====
这要在每个节点上查询这个状态,只查一个节点可能不准确,因为你的网络频繁断开,在查询节点看起来可能都还是好的,但在其他节点上看起来,该节点却可能已经失联了,或者进入被怀疑(SUSPICION)状态了。


通过 mysql client 执行kill 命令,操作后,事务长时间处理 killed的状态,但无法真正的结束,此时集群状态查询,原主节点为 unreachable,其他节点为online。
====
同上,kill事务后,也要通知其他节点回滚,但因为节点间通信非常不稳定,所以一直处于killed状态而不能真正结束。

归根结底,几点建议:
1. 确保各节点间网络【高效】、【稳定】。
2. 尽量少用大事务,需要大事务时,可以用循环的思路切成多个小事务运行。
3. 使用GreatSQL来跑MGR。
Guoxing

1

主题

0

博客

3

贡献

新手上路

Rank: 1

积分
4

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-5-8 01:40 , Processed in 0.017951 second(s), 14 queries , Redis On.
快速回复 返回顶部 返回列表