diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2020-10-16 20:19:09 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-09-07 09:50:11 +0530 |
commit | 31dbfb5e617b19ffea6ea6350207e48cdcd371d7 (patch) | |
tree | e82eaa278ba9cef602351daa9ee13893e113b788 | |
parent | 84c578c7952161fe5068fea003f0f8b1d62caa89 (diff) | |
download | mariadb-git-bb-10.5-MDEV-23836.tar.gz |
MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' inbb-10.5-MDEV-23836
Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK)
Analysis: KILL_QUERY is not ignored when local memory used exceeds maximum
session memory. Hence the query proceeds, OK is sent and we end up
reopening tables that are marked for reopen. During this, kill status is
eventually checked and assertion failure happens during trying to send error
message because OK has already been sent.
Fix: Ok is already sent so statement has already executed. It is too
late to give error. So ignore kill.
-rw-r--r-- | mysql-test/main/alter_table.result | 18 | ||||
-rw-r--r-- | mysql-test/main/alter_table.test | 22 | ||||
-rw-r--r-- | sql/lock.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 |
4 files changed, 44 insertions, 2 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index a43d9845947..84bbda194f8 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -3373,5 +3373,23 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; # +# MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in +# Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) +# +SET @max_session_mem_used_save= @@max_session_mem_used; +CREATE TABLE t1 (a INT); +SELECT * FROM t1; +a +ALTER TABLE x MODIFY xx INT; +ERROR 42S02: Table 'test.x' doesn't exist +SET SESSION max_session_mem_used= 8192; +LOCK TABLE t1 WRITE; +ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; +Warnings: +Note 1054 Unknown column 'b' in 't1' +SET SESSION max_session_mem_used = @max_session_mem_used_save; +UNLOCK TABLES; +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index e65a4edf13e..c838ad7d560 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -2568,5 +2568,27 @@ show create table t1; drop table t1; --echo # +--echo # MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in +--echo # Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) +--echo # + +SET @max_session_mem_used_save= @@max_session_mem_used; + +CREATE TABLE t1 (a INT); +SELECT * FROM t1; + +--error ER_NO_SUCH_TABLE +ALTER TABLE x MODIFY xx INT; + +SET SESSION max_session_mem_used= 8192; +LOCK TABLE t1 WRITE; + +ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; + +SET SESSION max_session_mem_used = @max_session_mem_used_save; +UNLOCK TABLES; +DROP TABLE t1; + +--echo # --echo # End of 10.5 tests --echo # diff --git a/sql/lock.cc b/sql/lock.cc index 559f1195b32..ec91655375e 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -356,7 +356,7 @@ bool mysql_lock_tables(THD *thd, MYSQL_LOCK *sql_lock, uint flags) end: THD_STAGE_INFO(thd, org_stage); - if (thd->killed) + if (thd->killed && !thd->get_stmt_da()->is_ok()) { thd->send_kill_message(); if (!rc) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 52d4fdefb8f..155f00a246d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2609,7 +2609,9 @@ void Locked_tables_list::mark_table_for_reopen(THD *thd, TABLE *table) bool Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) { - Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); + bool is_ok= thd->get_stmt_da()->is_ok(); + Open_table_context ot_ctx(thd, !is_ok ? MYSQL_OPEN_REOPEN: + MYSQL_OPEN_IGNORE_KILLED | MYSQL_OPEN_REOPEN); uint reopen_count= 0; MYSQL_LOCK *lock; MYSQL_LOCK *merged_lock; |