MDEV-33680 Server hangs or assertion fails upon SELECT with limited max_tmp_space_usage

The bug was that Aggregator_distinct::add() did not properly handle
write errors. (Old bug exposed by the new code).
This commit is contained in:
Monty 2024-04-06 12:07:49 +03:00 committed by Sergei Golubchik
parent b9f5793176
commit 865ef0f567
5 changed files with 26 additions and 3 deletions

View file

@ -150,4 +150,11 @@ INSERT INTO t1 VALUES
UPDATE t1 SET a = '' LIMIT 100;
ERROR HY000: Local temporary space limit reached
DROP TABLE t1;
#
# MDEV-33680 Server hangs or assertion fails upon SELECT with limited
# max_tmp_space_usage
#
set max_tmp_session_space_usage = 1024*1024;
select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000;
ERROR HY000: Global temporary space limit reached
# End of 11.5 tests

View file

@ -200,4 +200,13 @@ UPDATE t1 SET a = '' LIMIT 100;
DROP TABLE t1;
--echo #
--echo # MDEV-33680 Server hangs or assertion fails upon SELECT with limited
--echo # max_tmp_space_usage
--echo #
set max_tmp_session_space_usage = 1024*1024;
--error 201
select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000;
--echo # End of 11.5 tests

View file

@ -1026,7 +1026,10 @@ bool Aggregator_distinct::add()
}
if (unlikely((error= table->file->ha_write_tmp_row(table->record[0]))) &&
table->file->is_fatal_error(error, HA_CHECK_DUP))
{
table->file->print_error(error, MYF(0));
return TRUE;
}
return FALSE;
}
else

View file

@ -307,7 +307,7 @@ my_bool Expression_cache_tmptable::put_value(Item *value)
cache_table_param.start_recinfo,
&cache_table_param.recinfo,
error, 1, NULL))
goto err;
goto err2;
}
}
}
@ -318,6 +318,8 @@ my_bool Expression_cache_tmptable::put_value(Item *value)
DBUG_RETURN(FALSE);
err:
cache_table->file->print_error(error, MYF(0));
err2:
disable_cache();
DBUG_RETURN(TRUE);
}

View file

@ -22353,7 +22353,7 @@ bool open_tmp_table(TABLE *table)
RETURN
FALSE - OK
TRUE - Error
TRUE - Error. my_error() have been called
*/
@ -22569,7 +22569,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo,
RETURN
FALSE - OK
TRUE - Error
TRUE - Error ; my_error() has been called.
*/
/* Create internal MyISAM temporary table */
@ -22709,6 +22709,8 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo,
/*
If a HEAP table gets full, create a internal table in MyISAM or Maria
and copy all rows to this
In case of error, my_error() or handler::print_error() will be called.
*/