From edde990e35f4760e419bad1f0cb5b57ea9e2f863 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Mon, 26 Jul 2021 16:31:22 +0530 Subject: MDEV-23365: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon killed TRUNCATE Note: This is a backport of 1cb4caa66d5fd2a9bc095d68988324b7b358d70f from 10.3 Analysis: Assertion failure happens because less session memory is set and so table can't be reopened. So the statement can't be used. This error goes unreported. Fix: Return the error state. --- mysql-test/r/truncate.result | 22 ++++++++++++++++++++++ mysql-test/t/truncate.test | 29 +++++++++++++++++++++++++++++ sql/sql_truncate.cc | 4 +++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/truncate.result b/mysql-test/r/truncate.result index 48839f0eadb..0ab921c2438 100644 --- a/mysql-test/r/truncate.result +++ b/mysql-test/r/truncate.result @@ -159,3 +159,25 @@ HANDLER t1 READ FIRST; ERROR 42S02: Unknown table 't1' in HANDLER DROP TABLE t1; # End of 6.0 tests +# +# 10.2 Test +# +# MDEV-23365: Assertion `!is_set() || (m_status == DA_OK_BULK && +# is_bulk_op())' failed upon killed TRUNCATE +# +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +LOCK TABLE t1 READ; +connect con1,localhost,root,,test; +SET SESSION max_session_mem_used= 65536; +LOCK TABLE t1 WRITE; +connection default; +SELECT * FROM t1; +a +UNLOCK TABLES; +connection con1; +TRUNCATE TABLE t1; +ERROR HY000: The MariaDB server is running with the --max-thread-mem-used=65536 option so it cannot execute this statement +disconnect con1; +connection default; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test index c7a066cc203..b12a8fa50d4 100644 --- a/mysql-test/t/truncate.test +++ b/mysql-test/t/truncate.test @@ -163,3 +163,32 @@ DROP TABLE t1; --echo # End of 6.0 tests +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-23365: Assertion `!is_set() || (m_status == DA_OK_BULK && +--echo # is_bulk_op())' failed upon killed TRUNCATE +--echo # + +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +LOCK TABLE t1 READ; + +--connect (con1,localhost,root,,test) +SET SESSION max_session_mem_used= 65536; +--send + LOCK TABLE t1 WRITE; + +--connection default +SELECT * FROM t1; +UNLOCK TABLES; + +--connection con1 +--reap +--error ER_OPTION_PREVENTS_STATEMENT +TRUNCATE TABLE t1; + +--disconnect con1 +--connection default +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 7d1f630b88c..e5165c5a855 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -426,8 +426,10 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) error= dd_recreate_table(thd, table_ref->db, table_ref->table_name); if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd, false)) + { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - + error= 1; + } /* No need to binlog a failed truncate-by-recreate. */ binlog_stmt= !error; } -- cgit v1.2.1