MDEV-33285 - Assertion `m_table' failed in ha_perfschema::rnd_end on CHECKSUM TABLE

CHECKSUM TABLE causes variety of crashes when killed. This bug it not
specific to PERFORMANCE_SCHEMA.

Removed duplicate handler::ha_rnd_end() call.
This commit is contained in:
Sergey Vojtovich 2024-11-08 18:41:05 +04:00 committed by Sergei Golubchik
parent aef6f35989
commit b730abda09
4 changed files with 68 additions and 2 deletions

View file

@ -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';

View file

@ -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';

View file

@ -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]);

View file

@ -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;
}