Skip to content

Commit 34045af

Browse files
committed
MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA
don't implicitly commit or rollback in mysql_admin_table() unless the statement has CF_IMPLICIT_COMMIT_END flag.
1 parent 087ea8f commit 34045af

9 files changed

+36
-18
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set global my_cache.key_buffer_size = 1024*1024;
2+
create table t1 (i int) engine=myisam partition by hash (i) partitions 2;
3+
xa start 'xid';
4+
cache index t1 partition (non_existing_partition) in my_cache;
5+
Table Op Msg_type Msg_text
6+
test.t1 assign_to_keycache error Error in list of partitions to test.t1
7+
cache index t1 partition (p1) in my_cache;
8+
Table Op Msg_type Msg_text
9+
test.t1 assign_to_keycache status OK
10+
xa end 'xid';
11+
xa rollback 'xid';
12+
drop table t1;
13+
set global my_cache.key_buffer_size = 0;

mysql-test/r/implicit_commit.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ INSERT INTO db1.trans (a) VALUES (1);
561561
cache index t3 in keycache;
562562
CALL db1.test_if_commit();
563563
IMPLICIT COMMIT
564-
YES
564+
NO
565565
set global keycache.key_buffer_size=0;
566566
#
567567
# SQLCOM_PRELOAD_KEYS
@@ -570,7 +570,7 @@ INSERT INTO db1.trans (a) VALUES (1);
570570
load index into cache t3;
571571
CALL db1.test_if_commit();
572572
IMPLICIT COMMIT
573-
YES
573+
NO
574574
#
575575
# SQLCOM_FLUSH
576576
#

mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ master-bin.000001 # Gtid # # GTID #-#-#
140140
master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
141141
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
142142
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41)
143-
master-bin.000001 # Xid # # COMMIT /* XID */
144-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
145143
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40)
146-
master-bin.000001 # Xid # # COMMIT /* XID */
147-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
148144
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39)
149145
master-bin.000001 # Xid # # COMMIT /* XID */
150146
master-bin.000001 # Gtid # # GTID #-#-#

mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,8 @@ master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
145145
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
146146
master-bin.000001 # Table_map # # table_id: # (test.tt_1)
147147
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
148-
master-bin.000001 # Xid # # COMMIT /* XID */
149-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
150148
master-bin.000001 # Table_map # # table_id: # (test.tt_1)
151149
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
152-
master-bin.000001 # Xid # # COMMIT /* XID */
153-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
154150
master-bin.000001 # Table_map # # table_id: # (test.tt_1)
155151
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
156152
master-bin.000001 # Xid # # COMMIT /* XID */

mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ master-bin.000001 # Gtid # # GTID #-#-#
140140
master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int
141141
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
142142
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41)
143-
master-bin.000001 # Xid # # COMMIT /* XID */
144-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
145143
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40)
146-
master-bin.000001 # Xid # # COMMIT /* XID */
147-
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
148144
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39)
149145
master-bin.000001 # Xid # # COMMIT /* XID */
150146
master-bin.000001 # Gtid # # GTID #-#-#

mysql-test/t/assign_key_cache.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA
3+
#
4+
--source include/have_partition.inc
5+
set global my_cache.key_buffer_size = 1024*1024;
6+
create table t1 (i int) engine=myisam partition by hash (i) partitions 2;
7+
xa start 'xid';
8+
cache index t1 partition (non_existing_partition) in my_cache;
9+
cache index t1 partition (p1) in my_cache;
10+
xa end 'xid';
11+
xa rollback 'xid';
12+
drop table t1;
13+
set global my_cache.key_buffer_size = 0;

sql/sql_admin.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
10641064
}
10651065
else
10661066
{
1067-
if (trans_commit_stmt(thd) || trans_commit_implicit(thd))
1067+
if (trans_commit_stmt(thd) ||
1068+
(stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END) &&
1069+
trans_commit_implicit(thd)))
10681070
goto err;
10691071
}
10701072
close_thread_tables(thd);
@@ -1098,7 +1100,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
10981100
err:
10991101
/* Make sure this table instance is not reused after the failure. */
11001102
trans_rollback_stmt(thd);
1101-
trans_rollback(thd);
1103+
if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END))
1104+
trans_rollback(thd);
11021105
if (table && table->table)
11031106
{
11041107
table->table->m_needs_reopen= true;

sql/sql_parse.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
192192

193193

194194
/*
195-
Implicitly commit a active transaction if statement requires so.
195+
Check whether the statement implicitly commits an active transaction.
196196
197197
@param thd Thread handle.
198198
@param mask Bitmask used for the SQL command match.
199199
200200
@return 0 No implicit commit
201201
@return 1 Do a commit
202202
*/
203-
static bool stmt_causes_implicit_commit(THD *thd, uint mask)
203+
bool stmt_causes_implicit_commit(THD *thd, uint mask)
204204
{
205205
LEX *lex= thd->lex;
206206
bool skip= FALSE;

sql/sql_parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ bool check_identifier_name(LEX_STRING *str, uint max_char_length,
8484
uint err_code, const char *param_for_err_msg);
8585
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
8686
bool sqlcom_can_generate_row_events(const THD *thd);
87+
bool stmt_causes_implicit_commit(THD *thd, uint mask);
8788
bool is_update_query(enum enum_sql_command command);
8889
bool is_log_table_write_query(enum enum_sql_command command);
8990
bool alloc_query(THD *thd, const char *packet, uint packet_length);

0 commit comments

Comments
 (0)