From fffc9f585ddaed46dc3d157ebde3c1aeeb8a8c8c Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Sat, 24 Jan 2015 18:39:21 -0500 Subject: [PATCH] MDEV-7374 : Losing connection to MySQL while running ALTER TABLE Backport from 10.1. --- .../suite/wsrep/r/alter_table_innodb.result | 8 +++ .../suite/wsrep/t/alter_table_innodb.opt | 1 + .../suite/wsrep/t/alter_table_innodb.test | 10 ++++ storage/innobase/handler/ha_innodb.cc | 51 ++++++++++--------- storage/xtradb/handler/ha_innodb.cc | 51 ++++++++++--------- 5 files changed, 75 insertions(+), 46 deletions(-) create mode 100644 mysql-test/suite/wsrep/r/alter_table_innodb.result create mode 100644 mysql-test/suite/wsrep/t/alter_table_innodb.opt create mode 100644 mysql-test/suite/wsrep/t/alter_table_innodb.test diff --git a/mysql-test/suite/wsrep/r/alter_table_innodb.result b/mysql-test/suite/wsrep/r/alter_table_innodb.result new file mode 100644 index 00000000000..85017cec6e0 --- /dev/null +++ b/mysql-test/suite/wsrep/r/alter_table_innodb.result @@ -0,0 +1,8 @@ +# +# MDEV-7374 : Losing connection to MySQL while running ALTER TABLE +# +CREATE TABLE t1(i INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e; +ALTER TABLE t1 MODIFY i FLOAT; +DROP TABLE t1; diff --git a/mysql-test/suite/wsrep/t/alter_table_innodb.opt b/mysql-test/suite/wsrep/t/alter_table_innodb.opt new file mode 100644 index 00000000000..1e84570d7f6 --- /dev/null +++ b/mysql-test/suite/wsrep/t/alter_table_innodb.opt @@ -0,0 +1 @@ +--wsrep-on=0 diff --git a/mysql-test/suite/wsrep/t/alter_table_innodb.test b/mysql-test/suite/wsrep/t/alter_table_innodb.test new file mode 100644 index 00000000000..ca06be02a85 --- /dev/null +++ b/mysql-test/suite/wsrep/t/alter_table_innodb.test @@ -0,0 +1,10 @@ +--source include/have_innodb.inc + +--echo # +--echo # MDEV-7374 : Losing connection to MySQL while running ALTER TABLE +--echo # +CREATE TABLE t1(i INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e; +ALTER TABLE t1 MODIFY i FLOAT; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8b30334d198..268887e9fc2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5747,19 +5747,21 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) - { - case WSREP_TRX_OK: - break; - case WSREP_TRX_SIZE_EXCEEDED: - case WSREP_TRX_CERT_FAIL: - case WSREP_TRX_ERROR: - DBUG_RETURN(1); - } + if (wsrep_on(user_thd)) { + switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) + { + case WSREP_TRX_OK: + break; + case WSREP_TRX_SIZE_EXCEEDED: + case WSREP_TRX_CERT_FAIL: + case WSREP_TRX_ERROR: + DBUG_RETURN(1); + } - if (binlog_hton->commit(binlog_hton, user_thd, 1)) - DBUG_RETURN(1); - wsrep_post_commit(user_thd, TRUE); + if (binlog_hton->commit(binlog_hton, user_thd, 1)) + DBUG_RETURN(1); + wsrep_post_commit(user_thd, TRUE); + } #endif /* WITH_WSREP */ /* Source table is not in InnoDB format: no need to re-acquire locks on it. */ @@ -5772,18 +5774,21 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) - { - case WSREP_TRX_OK: - break; - case WSREP_TRX_SIZE_EXCEEDED: - case WSREP_TRX_CERT_FAIL: - case WSREP_TRX_ERROR: - DBUG_RETURN(1); + if (wsrep_on(user_thd)) { + switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) + { + case WSREP_TRX_OK: + break; + case WSREP_TRX_SIZE_EXCEEDED: + case WSREP_TRX_CERT_FAIL: + case WSREP_TRX_ERROR: + DBUG_RETURN(1); + } + + if (binlog_hton->commit(binlog_hton, user_thd, 1)) + DBUG_RETURN(1); + wsrep_post_commit(user_thd, TRUE); } - if (binlog_hton->commit(binlog_hton, user_thd, 1)) - DBUG_RETURN(1); - wsrep_post_commit(user_thd, TRUE); #endif /* WITH_WSREP */ /* Ensure that there are no other table locks than LOCK_IX and LOCK_AUTO_INC on the destination table. */ diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 8c881a07123..9dcabeccce8 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -6711,19 +6711,21 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) - { - case WSREP_TRX_OK: - break; - case WSREP_TRX_SIZE_EXCEEDED: - case WSREP_TRX_CERT_FAIL: - case WSREP_TRX_ERROR: - DBUG_RETURN(1); - } + if (wsrep_on(user_thd)) { + switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) + { + case WSREP_TRX_OK: + break; + case WSREP_TRX_SIZE_EXCEEDED: + case WSREP_TRX_CERT_FAIL: + case WSREP_TRX_ERROR: + DBUG_RETURN(1); + } - if (binlog_hton->commit(binlog_hton, user_thd, 1)) - DBUG_RETURN(1); - wsrep_post_commit(user_thd, TRUE); + if (binlog_hton->commit(binlog_hton, user_thd, 1)) + DBUG_RETURN(1); + wsrep_post_commit(user_thd, TRUE); + } #endif /* WITH_WSREP */ /* Source table is not in InnoDB format: no need to re-acquire locks on it. */ @@ -6736,18 +6738,21 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) - { - case WSREP_TRX_OK: - break; - case WSREP_TRX_SIZE_EXCEEDED: - case WSREP_TRX_CERT_FAIL: - case WSREP_TRX_ERROR: - DBUG_RETURN(1); + if (wsrep_on(user_thd)) { + switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) + { + case WSREP_TRX_OK: + break; + case WSREP_TRX_SIZE_EXCEEDED: + case WSREP_TRX_CERT_FAIL: + case WSREP_TRX_ERROR: + DBUG_RETURN(1); + } + + if (binlog_hton->commit(binlog_hton, user_thd, 1)) + DBUG_RETURN(1); + wsrep_post_commit(user_thd, TRUE); } - if (binlog_hton->commit(binlog_hton, user_thd, 1)) - DBUG_RETURN(1); - wsrep_post_commit(user_thd, TRUE); #endif /* WITH_WSREP */ /* Ensure that there are no other table locks than LOCK_IX and LOCK_AUTO_INC on the destination table. */