Skip to content

Commit 53b9f75

Browse files
author
Nirbhay Choubey
committed
MDEV-7374 : Losing connection to MySQL while running ALTER TABLE
Backport from 10.1.
1 parent b520120 commit 53b9f75

File tree

5 files changed

+75
-48
lines changed

5 files changed

+75
-48
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# MDEV-7374 : Losing connection to MySQL while running ALTER TABLE
3+
#
4+
CREATE TABLE t1(i INT) ENGINE=INNODB;
5+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
6+
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e;
7+
ALTER TABLE t1 MODIFY i FLOAT;
8+
DROP TABLE t1;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--wsrep-on=0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--source include/have_innodb.inc
2+
3+
--echo #
4+
--echo # MDEV-7374 : Losing connection to MySQL while running ALTER TABLE
5+
--echo #
6+
CREATE TABLE t1(i INT) ENGINE=INNODB;
7+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
8+
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e;
9+
ALTER TABLE t1 MODIFY i FLOAT;
10+
DROP TABLE t1;

storage/innobase/handler/ha_innodb.cc

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7470,19 +7470,21 @@ ha_innobase::write_row(
74707470
;
74717471
} else if (src_table == prebuilt->table) {
74727472
#ifdef WITH_WSREP
7473-
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
7474-
{
7475-
case WSREP_TRX_OK:
7476-
break;
7477-
case WSREP_TRX_SIZE_EXCEEDED:
7478-
case WSREP_TRX_CERT_FAIL:
7479-
case WSREP_TRX_ERROR:
7480-
DBUG_RETURN(1);
7481-
}
7473+
if (wsrep_on(user_thd)) {
7474+
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
7475+
{
7476+
case WSREP_TRX_OK:
7477+
break;
7478+
case WSREP_TRX_SIZE_EXCEEDED:
7479+
case WSREP_TRX_CERT_FAIL:
7480+
case WSREP_TRX_ERROR:
7481+
DBUG_RETURN(1);
7482+
}
74827483

7483-
if (binlog_hton->commit(binlog_hton, user_thd, 1))
7484-
DBUG_RETURN(1);
7485-
wsrep_post_commit(user_thd, TRUE);
7484+
if (binlog_hton->commit(binlog_hton, user_thd, 1))
7485+
DBUG_RETURN(1);
7486+
wsrep_post_commit(user_thd, TRUE);
7487+
}
74867488
#endif /* WITH_WSREP */
74877489
/* Source table is not in InnoDB format:
74887490
no need to re-acquire locks on it. */
@@ -7495,19 +7497,21 @@ ha_innobase::write_row(
74957497
prebuilt->sql_stat_start = TRUE;
74967498
} else {
74977499
#ifdef WITH_WSREP
7498-
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
7499-
{
7500-
case WSREP_TRX_OK:
7501-
break;
7502-
case WSREP_TRX_SIZE_EXCEEDED:
7503-
case WSREP_TRX_CERT_FAIL:
7504-
case WSREP_TRX_ERROR:
7505-
DBUG_RETURN(1);
7506-
}
7500+
if (wsrep_on(user_thd)) {
7501+
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
7502+
{
7503+
case WSREP_TRX_OK:
7504+
break;
7505+
case WSREP_TRX_SIZE_EXCEEDED:
7506+
case WSREP_TRX_CERT_FAIL:
7507+
case WSREP_TRX_ERROR:
7508+
DBUG_RETURN(1);
7509+
}
75077510

7508-
if (binlog_hton->commit(binlog_hton, user_thd, 1))
7509-
DBUG_RETURN(1);
7510-
wsrep_post_commit(user_thd, TRUE);
7511+
if (binlog_hton->commit(binlog_hton, user_thd, 1))
7512+
DBUG_RETURN(1);
7513+
wsrep_post_commit(user_thd, TRUE);
7514+
}
75117515
#endif /* WITH_WSREP */
75127516
/* Ensure that there are no other table locks than
75137517
LOCK_IX and LOCK_AUTO_INC on the destination table. */

storage/xtradb/handler/ha_innodb.cc

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8045,19 +8045,21 @@ ha_innobase::write_row(
80458045
;
80468046
} else if (src_table == prebuilt->table) {
80478047
#ifdef WITH_WSREP
8048-
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
8049-
{
8050-
case WSREP_TRX_OK:
8051-
break;
8052-
case WSREP_TRX_SIZE_EXCEEDED:
8053-
case WSREP_TRX_CERT_FAIL:
8054-
case WSREP_TRX_ERROR:
8055-
DBUG_RETURN(1);
8056-
}
8048+
if (wsrep_on(user_thd)) {
8049+
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
8050+
{
8051+
case WSREP_TRX_OK:
8052+
break;
8053+
case WSREP_TRX_SIZE_EXCEEDED:
8054+
case WSREP_TRX_CERT_FAIL:
8055+
case WSREP_TRX_ERROR:
8056+
DBUG_RETURN(1);
8057+
}
80578058

8058-
if (binlog_hton->commit(binlog_hton, user_thd, 1))
8059-
DBUG_RETURN(1);
8060-
wsrep_post_commit(user_thd, TRUE);
8059+
if (binlog_hton->commit(binlog_hton, user_thd, 1))
8060+
DBUG_RETURN(1);
8061+
wsrep_post_commit(user_thd, TRUE);
8062+
}
80618063
#endif /* WITH_WSREP */
80628064
/* Source table is not in InnoDB format:
80638065
no need to re-acquire locks on it. */
@@ -8070,19 +8072,21 @@ ha_innobase::write_row(
80708072
prebuilt->sql_stat_start = TRUE;
80718073
} else {
80728074
#ifdef WITH_WSREP
8073-
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
8074-
{
8075-
case WSREP_TRX_OK:
8076-
break;
8077-
case WSREP_TRX_SIZE_EXCEEDED:
8078-
case WSREP_TRX_CERT_FAIL:
8079-
case WSREP_TRX_ERROR:
8080-
DBUG_RETURN(1);
8081-
}
8075+
if (wsrep_on(user_thd)) {
8076+
switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
8077+
{
8078+
case WSREP_TRX_OK:
8079+
break;
8080+
case WSREP_TRX_SIZE_EXCEEDED:
8081+
case WSREP_TRX_CERT_FAIL:
8082+
case WSREP_TRX_ERROR:
8083+
DBUG_RETURN(1);
8084+
}
80828085

8083-
if (binlog_hton->commit(binlog_hton, user_thd, 1))
8084-
DBUG_RETURN(1);
8085-
wsrep_post_commit(user_thd, TRUE);
8086+
if (binlog_hton->commit(binlog_hton, user_thd, 1))
8087+
DBUG_RETURN(1);
8088+
wsrep_post_commit(user_thd, TRUE);
8089+
}
80868090
#endif /* WITH_WSREP */
80878091
/* Ensure that there are no other table locks than
80888092
LOCK_IX and LOCK_AUTO_INC on the destination table. */

0 commit comments

Comments
 (0)