分析MySQL中关于Bug的解决方法
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,这篇文章主要介绍"分析MySQL中关于Bug的解决方法",在日常操作中,相信很多人在分析MySQL中关于Bug的解决方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"分
千家信息网最后更新 2026年11月03日分析MySQL中关于Bug的解决方法
这篇文章主要介绍"分析MySQL中关于Bug的解决方法",在日常操作中,相信很多人在分析MySQL中关于Bug的解决方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"分析MySQL中关于Bug的解决方法"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
故障
下面是commit
$ git show a43f7d5a6130550619afad3fb513c98e00dc505ecommit a43f7d5a6130550619afad3fb513c98e00dc505eAuthor: Daogang QuDate: Wed Jan 20 09:25:36 2016 +0800 Bug#22130929 GTID_NEXT AND BEGIN BEHAVIOR IS DIFFERENT B/W BINLOG AND BINLOG-LESS SERVER Problem ======= When binlog is enabled, we do not save the gtid specified by GTID_NEXT into GLOBAL@gtid_executed when committing an empty transaction caused by a 'BEGIN' command. But we save the gtid into GLOBAL@gtid_executed in the case when binlog is disabled. Fix === When @@SESSION.GTID_NEXT == 'UUID:NUMBER', the command 'BEGIN' causes an error 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside an empty/a non-empty transaction regardless of being binlogless or not, since it causes an implicit commit like other DDLs. And we do not save the gtid specified by GTID_NEXT into GLOBAL@gtid_executed in the case.diff --git a/mysql-test/extra/binlog_tests/gtid_next_begin_caused_trx.test b/mysql-test/extra/binlog_tests/gtid_next_begin_caused_trx.testnew file mode 100644index 00000000000..1459bcdf775--- /dev/null+++ b/mysql-test/extra/binlog_tests/gtid_next_begin_caused_trx.test@@ -0,0 +1,76 @@+# ==== Purpose ====+#+# When @@SESSION.GTID_NEXT == 'UUID:NUMBER', verify that the command+# 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# an empty/a non-empty transaction, since it causes an implicit+# commit. We do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+# ==== Implementation ====+#+# 1) Set @@SESSION.GTID_NEXT == 'UUID:NUMBER'+# 2) Execute a 'BEGIN' command to start a transaction.+# 3) Execute another 'BEGIN' command to check if it causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET'+# inside an empty transaction, and we do not save the gtid+# specified by GTID_NEXT into GLOBAL@gtid_executed.+# 4) Execute an 'INSERT' statement.+# 5) Execute the third 'BEGIN' command to check if it causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET'+# inside a non-empty transaction, and we do not save the gtid+# specified by GTID_NEXT into GLOBAL@gtid_executed.+# 6) Check that we save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed when committing the transaction.+#+# ==== References ====+#+# Bug#22130929 GTID_NEXT AND BEGIN BEHAVIOR IS DIFFERENT B/W BINLOG AND BINLOG-LESS SERVER+# Caller: suite/binlog/t/binlog_gtid_next_begin_caused_trx.test+# Caller: t/no_binlog_gtid_next_begin_caused_trx.test+#++SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';+CREATE TABLE t1 (c1 INT);+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2';+BEGIN;++--echo #+--echo # Check that the command 'BEGIN' causes an error+--echo # 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+--echo # an empty transaction, since it causes an implicit commit. And we+--echo # do not save the gtid specified by GTID_NEXT into+--echo # GLOBAL@gtid_executed in the case.+--echo #+--error ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET+BEGIN;+--let $assert_text= Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2+--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1"+--source include/assert.inc++INSERT INTO t1 VALUES (1);+--echo #+--echo # Check that the command 'BEGIN' causes an error+--echo # 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+--echo # a non-empty transaction, since it causes an implicit commit. And+--echo # we do not save the gtid specified by GTID_NEXT into+--echo # GLOBAL@gtid_executed in the case.+--echo #+--error ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET+BEGIN;+--let $assert_text= Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2+--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1"+--source include/assert.inc++--echo #+--echo # Check that we save the gtid specified by GTID_NEXT into+--echo # GLOBAL@gtid_executed when committing the transaction.+--echo #+COMMIT;+--let $assert_text= Committed gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2+--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1-2"+--source include/assert.inc++SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:3';+DROP TABLE t1;+diff --git a/mysql-test/r/no_binlog_gtid_next_begin_caused_trx.result b/mysql-test/r/no_binlog_gtid_next_begin_caused_trx.resultnew file mode 100644index 00000000000..44f6216c1b6--- /dev/null+++ b/mysql-test/r/no_binlog_gtid_next_begin_caused_trx.result@@ -0,0 +1,34 @@+RESET MASTER;+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';+CREATE TABLE t1 (c1 INT);+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2';+BEGIN;+#+# Check that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# an empty transaction, since it causes an implicit commit. And we+# do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+BEGIN;+ERROR HY000: Cannot execute statements with implicit commit inside a transaction when @@SESSION.GTID_NEXT == 'UUID:NUMBER'.+include/assert.inc [Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+INSERT INTO t1 VALUES (1);+#+# Check that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# a non-empty transaction, since it causes an implicit commit. And+# we do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+BEGIN;+ERROR HY000: Cannot execute statements with implicit commit inside a transaction when @@SESSION.GTID_NEXT == 'UUID:NUMBER'.+include/assert.inc [Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+#+# Check that we save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed when committing the transaction.+#+COMMIT;+include/assert.inc [Committed gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:3';+DROP TABLE t1;diff --git a/mysql-test/suite/binlog/r/binlog_gtid_next_begin_caused_trx.result b/mysql-test/suite/binlog/r/binlog_gtid_next_begin_caused_trx.resultnew file mode 100644index 00000000000..44f6216c1b6--- /dev/null+++ b/mysql-test/suite/binlog/r/binlog_gtid_next_begin_caused_trx.result@@ -0,0 +1,34 @@+RESET MASTER;+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';+CREATE TABLE t1 (c1 INT);+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2';+BEGIN;+#+# Check that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# an empty transaction, since it causes an implicit commit. And we+# do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+BEGIN;+ERROR HY000: Cannot execute statements with implicit commit inside a transaction when @@SESSION.GTID_NEXT == 'UUID:NUMBER'.+include/assert.inc [Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+INSERT INTO t1 VALUES (1);+#+# Check that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# a non-empty transaction, since it causes an implicit commit. And+# we do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+BEGIN;+ERROR HY000: Cannot execute statements with implicit commit inside a transaction when @@SESSION.GTID_NEXT == 'UUID:NUMBER'.+include/assert.inc [Dose not commit gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+#+# Check that we save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed when committing the transaction.+#+COMMIT;+include/assert.inc [Committed gtid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2]+SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:3';+DROP TABLE t1;diff --git a/mysql-test/suite/binlog/t/binlog_gtid_next_begin_caused_trx.test b/mysql-test/suite/binlog/t/binlog_gtid_next_begin_caused_trx.testnew file mode 100644index 00000000000..dc12cb95fa8--- /dev/null+++ b/mysql-test/suite/binlog/t/binlog_gtid_next_begin_caused_trx.test@@ -0,0 +1,30 @@+# ==== Purpose ====+#+# When binlog is enabled and @@SESSION.GTID_NEXT == 'UUID:NUMBER',+# verify that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# an empty/a non-empty transaction, since it causes an implicit+# commit. We do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+# ==== Implementation ====+#+# See extra/binlog_tests/gtid_next_begin_caused_trx.test+#+# ==== References ====+#+# Bug#22130929 GTID_NEXT AND BEGIN BEHAVIOR IS DIFFERENT B/W BINLOG AND BINLOG-LESS SERVER+#++# Test in this file is binlog format agnostic, thus no need+# to rerun them for every format.+--source include/have_binlog_format_row.inc+--source include/have_gtid.inc+# Test is not required to run against embedded server+--source include/not_embedded.inc++# Make sure the test is repeatable+RESET MASTER;++--source extra/binlog_tests/gtid_next_begin_caused_trx.test+diff --git a/mysql-test/t/no_binlog_gtid_next_begin_caused_trx-master.opt b/mysql-test/t/no_binlog_gtid_next_begin_caused_trx-master.optnew file mode 100644index 00000000000..f3fd62da9b7--- /dev/null+++ b/mysql-test/t/no_binlog_gtid_next_begin_caused_trx-master.opt@@ -0,0 +1,2 @@+--gtid_mode=ON+--enforce_gtid_consistencydiff --git a/mysql-test/t/no_binlog_gtid_next_begin_caused_trx.test b/mysql-test/t/no_binlog_gtid_next_begin_caused_trx.testnew file mode 100644index 00000000000..71f9833827d--- /dev/null+++ b/mysql-test/t/no_binlog_gtid_next_begin_caused_trx.test@@ -0,0 +1,28 @@+# ==== Purpose ====+#+# When binlog is disabled and @@SESSION.GTID_NEXT == 'UUID:NUMBER',+# verify that the command 'BEGIN' causes an error+# 'ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET' inside+# an empty/a non-empty transaction, since it causes an implicit+# commit. We do not save the gtid specified by GTID_NEXT into+# GLOBAL@gtid_executed in the case.+#+# ==== Implementation ====+#+# See extra/binlog_tests/gtid_next_begin_caused_trx.test+#+# ==== References ====+#+# Bug#22130929 GTID_NEXT AND BEGIN BEHAVIOR IS DIFFERENT B/W BINLOG AND BINLOG-LESS SERVER+#+++# Test is not required to run against embedded server+--source include/not_embedded.inc+# Should be tested against "binlog disabled" server+--source include/not_log_bin.inc++# Make sure the test is repeatable+RESET MASTER;++--source extra/binlog_tests/gtid_next_begin_caused_trx.testdiff --git a/sql/rpl_gtid_execution.cc b/sql/rpl_gtid_execution.ccindex ec36772e8c9..65161e2ca97 100644--- a/sql/rpl_gtid_execution.cc+++ b/sql/rpl_gtid_execution.cc@@ -1,4 +1,4 @@-/* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.+/* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as@@ -453,7 +453,8 @@ enum_gtid_statement_status gtid_pre_statement_checks(THD *thd) DBUG_ASSERT(gtid_next->type != AUTOMATIC_GROUP || thd->owned_gtid.is_empty());- if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_BEGIN) &&+ if ((stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_BEGIN) ||+ thd->lex->sql_command == SQLCOM_BEGIN) && thd->in_active_multi_stmt_transaction() && gtid_next->type == GTID_GROUP) {
到此,关于"分析MySQL中关于Bug的解决方法"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
方法
中关
分析
学习
更多
帮助
实用
接下来
故障
文章
理论
知识
篇文章
网站
资料
跟着
问题
好用
实践
解答
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技名片
互联网科技公司排名
重庆互联网络科技
互联网未来科技
互联网科技公司官网
深圳天众互联网科技公司
国外互联网科技网站
甘肃拓世互联网科技有限公司
联恩商钥互联网科技有限公司
上海电发互联网科技有限公司
安控科技rtu产品工业互联网
互联网科技公司有风险吗
青海科技产业互联网发展
互联网科技创新的路径
华中科技大学互联网的牛人
互联网金融科技元年
黑科技 体验场景 互联网大会
深圳无忧互联网科技
风投北京互联网科技
全球科技与互联网公司市值变化
上海挚品互联网科技有限公司
科技互联网公司装修
美国互联网科技巨头监管
中国 科技 互联网
互联网金融科技创新
互联网科技论坛
撒么互联网科技公司
互联网教育科技公司vipkid
郑州欣桑互联网科技有限公司
互联网科技大佬云集