diff --git a/mysql-test/main/kill_debug.result b/mysql-test/main/kill_debug.result index 061e7602383..40047ef7eb7 100644 --- a/mysql-test/main/kill_debug.result +++ b/mysql-test/main/kill_debug.result @@ -237,3 +237,29 @@ kill $id; set debug_sync='now SIGNAL go3'; drop table t1; set debug_sync='reset'; +# +# MDEV-33285 - Assertion `m_table' failed in ha_perfschema::rnd_end on +# CHECKSUM TABLE +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(1); +SET debug_sync='mysql_checksum_table_after_calculate_checksum SIGNAL parked WAIT_FOR go'; +CHECKSUM TABLE t1; +connect con1, localhost, root; +connection con1; +SET debug_sync='now WAIT_FOR parked'; +KILL QUERY id; +SET debug_sync='now SIGNAL go'; +connection default; +ERROR 70100: Query execution was interrupted +SET debug_sync='mysql_checksum_table_before_calculate_checksum SIGNAL parked WAIT_FOR go'; +CHECKSUM TABLE t1; +connection con1; +SET debug_sync='now WAIT_FOR parked'; +KILL QUERY id; +SET debug_sync='now SIGNAL go'; +connection default; +ERROR 70100: Query execution was interrupted +DROP TABLE t1; +disconnect con1; +SET debug_sync='RESET'; diff --git a/mysql-test/main/kill_debug.test b/mysql-test/main/kill_debug.test index 32a764004e3..0285fb48bd2 100644 --- a/mysql-test/main/kill_debug.test +++ b/mysql-test/main/kill_debug.test @@ -316,3 +316,39 @@ evalp kill $id; set debug_sync='now SIGNAL go3'; drop table t1; set debug_sync='reset'; + + +--echo # +--echo # MDEV-33285 - Assertion `m_table' failed in ha_perfschema::rnd_end on +--echo # CHECKSUM TABLE +--echo # +let $id= `select connection_id()`; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(1); +SET debug_sync='mysql_checksum_table_after_calculate_checksum SIGNAL parked WAIT_FOR go'; +send CHECKSUM TABLE t1; + +connect con1, localhost, root; +connection con1; +SET debug_sync='now WAIT_FOR parked'; +replace_result $id id; +eval KILL QUERY $id; +SET debug_sync='now SIGNAL go'; +connection default; +error ER_QUERY_INTERRUPTED; +reap; + +SET debug_sync='mysql_checksum_table_before_calculate_checksum SIGNAL parked WAIT_FOR go'; +send CHECKSUM TABLE t1; +connection con1; +SET debug_sync='now WAIT_FOR parked'; +replace_result $id id; +eval KILL QUERY $id; +SET debug_sync='now SIGNAL go'; + +connection default; +error ER_QUERY_INTERRUPTED; +reap; +DROP TABLE t1; +disconnect con1; +SET debug_sync='RESET'; diff --git a/sql/handler.cc b/sql/handler.cc index 979e9315571..c3aa1c64906 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5584,7 +5584,10 @@ int handler::calculate_checksum() for (;;) { if (thd->killed) - return HA_ERR_ABORTED_BY_USER; + { + error= HA_ERR_ABORTED_BY_USER; + break; + } ha_checksum row_crc= 0; error= ha_rnd_next(table->record[0]); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e906d8a2a62..2162850172b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -12237,14 +12237,15 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, protocol->store_null(); else { + DEBUG_SYNC(thd, "mysql_checksum_table_before_calculate_checksum"); int error= t->file->calculate_checksum(); + DEBUG_SYNC(thd, "mysql_checksum_table_after_calculate_checksum"); if (thd->killed) { /* we've been killed; let handler clean up, and remove the partial current row from the recordset (embedded lib) */ - t->file->ha_rnd_end(); thd->protocol->remove_last_row(); goto err; }