MySQL 8的MGR集群中设置autocommit=0引起ERROR 1064 (42000)错误

这篇具有很好参考价值的文章主要介绍了MySQL 8的MGR集群中设置autocommit=0引起ERROR 1064 (42000)错误。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在一套MySQL MGR集群测试环境中,同事测试时,在my.cnf参数文件中修改了autocommit参数(修改为autocommit=0),结果上周五,由于系统管理员要升级RHEL 8.8的系统补丁,所以将这这三台MySQL的数据库服务关闭了,升级完RHEL 8.8的系统补丁后,启动MySQL的集群时遇到了“ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction”错误

当前测试环境为MySQL 8.0.33,具体操作如下所示:

mysql> show variables like 'group_replication_bootstrap_group';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| group_replication_bootstrap_group | OFF   |
+-----------------------------------+-------+
1 row in set (0.02 sec)

mysql> set global group_replication_bootstrap_group=on;
Query OK, 0 rows affected (0.00 sec)

mysql>  show variables like 'group_replication_bootstrap_group';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| group_replication_bootstrap_group | ON    |
+-----------------------------------+-------+
1 row in set (0.00 sec)

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST  | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | f8eea283-c942-11ed-a4e9-0050569783ac | mydbmysqlu03 |        7306 | OFFLINE      |             |                | MySQL                      |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
1 row in set (0.00 sec)

mysql> START GROUP_REPLICATION;
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction
mysql> START GROUP_REPLICATION;
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction
mysql> SET autocommit=1;
Query OK, 0 rows affected (0.00 sec)

mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (1.60 sec)

mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
Query OK, 0 rows affected (0.00 sec)

mysql>  select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST  | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | f8eea283-c942-11ed-a4e9-0050569783ac | mydbmysqlu03 |        7306 | ONLINE       | PRIMARY     | 8.0.33         | MySQL                      |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+----------------------------+
1 row in set (0.00 sec)

mysql> exit

当时看到错误ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction时,心里隐隐猜测可能是这个参数的变更导致了这个错误出现,因为之前多次测试过MGR集群的重启、切换主节点、删除节点等都没遇到问题,而最近就是因为相关测试修改了这个参数,于是将事务自动提交开启(autocommit=1)后,问题解决了。后面搜索了一下相关资料,发现参数autocommit还真的会引起这个错误,下面是官方文档[1]中用户反馈/报告的一个"Bug"

[6 Dec 2019 15:23] Sergey Kuzmichev
Description:
With autocommit=0, after running a SELECT on mysql.slave_master_info, neither START GROUP_REPLICATION nor STOP GROUP_REPLICATION will work in the same connection.
Error reported is:
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction

This has impact on mysql shell, as it will fail to remove an instance from the cluster under some circumstances.

How to repeat:
In the same connection, run:

SET autocommit=0;
SELECT * FROM mysql.slave_master_info;
START GROUP_REPLICATION;

Error reported:

ERROR 1192 (HY000): Can'
t execute the given command because you have active locked tables or an active transaction
[9 Dec 2019 8:46] Sergey Kuzmichev
Since with autocommit=0 transaction is always open for a session, the error will be reported for start/stop after any table is queried and transaction is actually started. This is not a bug.

MySQL Shell, however, might end up not being able to remove an instance due to this, but that's a different issue.
[10 Dec 2019 10:56] Sergey Kuzmichev
After some further consideration, it'
s still at least curious that start/stop group_replication behaves differently than regular start/stop slave does. The latter command will implicitly commit the transaction. Is there a reason for the difference in behavior?

#autocommit=0
mysql> select * from test;
Empty set (0.00 sec)

mysql> start group_replication;
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction
mysql> start slave;
ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
mysql> start group_replication;
ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.
[10 Dec 2019 13:05] MySQL Verification Team
Hi,

Thanks for the report, verified as described. Can'
t say really if the code or only documentation will change as the workaround is rather simple.

thanks

参考资料

[1]

Bug #97917: https://bugs.mysql.com/bug.php?id=97917#:~:text=How%20to%20repeat%3A%20In%20the%20same%20connection%2C%20run%3A,active%20transaction%20%5B9%20Dec%202019%208%3A46%5D%20Sergey%20Kuzmichev文章来源地址https://www.toymoban.com/news/detail-493782.html

到了这里,关于MySQL 8的MGR集群中设置autocommit=0引起ERROR 1064 (42000)错误的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • SQL 错误 [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to yo

    在为用户指定数据的时候,报错了,SQL 错误 [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to yo 原因 出现这个错误是因为数据库名称 jeecg-boot 包含了不允许的字符(如连字符-)。根据 MySQL 文档,数据库名、表名和列名等标识符应该只包含字母、数字、下

    2024年04月17日
    浏览(62)
  • 记录DBeaver报SQL 错误 [1064] [42000]: #42000的一个坑

    在这里插入图片描述 一般情况下报SQL 错误 [1064] [42000]: #42000的错误是因为SQL语句中 有冲突 。 但是!!! 但是!!! 但是!!! DBeaver在执行SQL语句时,如果 超过两条同时执行 的话,必须要使用“ 执行SQL脚本 ”。 使用“执行SQL语句”选项的话就会报42000错误!

    2024年02月12日
    浏览(30)
  • StarRocks案例5: hive外表报错starrocks [42000][1064] hdfsOpenFile failed

    StarRocks版本 2.5.5 现在需要使用hive外表,然后根据官网的的命令创建了hive resource CREATE EXTERNAL RESOURCE “hive0” PROPERTIES ( “type” = “hive”, “hive.metastore.uris” = “thrift://myhadoop:9083” ); 然后查询报错: StarRocks的committer在论坛回复我了,原来是打包的问题。 没想到打包名字居然是

    2024年02月09日
    浏览(28)
  • MySQL Shell如何接管手动搭建(含仲裁节点)MGR集群

    本文源自GreatSQL社区用户的一次提问: Q:一个包含仲裁节点( ARBITRATOR )的GreatSQL MGR集群,一开始是用手动方式构建,后来想用MySQL Shell接管,可以吗? A:是可以的,不过也有一定局限性 具体的操作如下 可以看到三个节点都是 ONLINE 状态 连接 Primary 节点,查看下原来的账户

    2024年02月05日
    浏览(36)
  • 已解决mysql报错ERROR 1049 (42000): Unknown database ‘数据库‘

    已解决mysql报错ERROR 1049 (42000): Unknown database ‘数据库‘ 对于错误代码1049(42000):Unknown database ‘数据库‘,这个错误通常表示您正在尝试访问一个不存在的数据库。 下滑查看解决方法 要解决这个问题,您可以按照以下步骤进行操作: 确认数据库名称:首先,请确保您正在

    2024年02月16日
    浏览(30)
  • 登陆mysql提示 :ERROR 1044 (42000): Access denied for user ‘‘@‘localhost‘ to database ‘mysql‘

    再次登陆mysql如提示 : ERROR 1044 (42000): Access denied for user \\\'\\\'@\\\'localhost\\\' to database \\\'mysql\\\' 这个错误是因为mysql数据库的user表里,存在用户名为空的账户即匿名账户,实际上是匿名登录的, 通过错误提示里的\\\'\\\'@\\\'localhost\\\'可以看出来 ,虽然登录时使用命令mysql -u root -p ,指定了用户是r

    2024年02月16日
    浏览(29)
  • MySQL报错:ERROR 1118 (42000): Row size too large. 或者 Row size too large (> 8126).

    今天拿到一个建语句时,大概二百多个字段,然后大部分类型是 string 的,要求建 MySQL 的表。首先将 string 替换为 varchar(xx),然后执行了一下语句,报错如下所示: ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhe

    2023年04月09日
    浏览(34)
  • mysql:Error 3948 (42000): Loading local data is disabled; this must be enabled on both the client an

    上面图片是AI创作,未经允许,不可商用哦!如有更多需要,可私戳! 执行项目过程中意外出现的报错,之前也没有遇到过 报错信息如下: 翻译如下: 看报错信息感觉是和数据库有一定关系,网上搜索该错误,也都直指mysql中的一个参数: local_infile 需要指定该参数为开启状

    2024年02月02日
    浏览(26)
  • pycharm中的python与mysql(1064):“You have an error in your SQL syntax; check the manual that corresponds

    1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \\\'‘director’,‘star’,‘score’) values (‘奥利 维埃·纳卡什’,‘弗朗索瓦·克é’ at line 1” 这个错误原因是在pycharm里敲代码时,将python语法与mysql语法混淆了。 mysql语法

    2024年02月16日
    浏览(26)
  • 错误代码: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser

             翻译一下就是: SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,了解“……”附近要使用的正确语法。         会出现这种问题,大部分都是因为自己的粗心大意啦~ 第一步:         先检查一下自己写的SQL语句中的符号是否有中文的,有的话改

    2024年02月12日
    浏览(51)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包