Details
Description
Reproduce
--source include/have_debug_sync.inc
|
|
|
create table t1 (a int, b int as (a + 1) virtual); |
insert into t1 (a) values (1); |
flush tables;
|
|
|
connect con1, localhost, root; |
let $con1_id= `select connection_id()`; |
set debug_sync= 'TABLE_after_field_clone signal opening wait_for go'; |
send select * from t1; |
|
|
connection default; |
set debug_sync= 'now wait_for opening'; |
--replace_result $con1_id CON1_ID
|
eval kill query $con1_id;
|
|
|
connection con1; |
--error ER_QUERY_INTERRUPTED
|
reap;
|
show warnings;
|
|
|
disconnect con1;
|
connection default; |
set debug_sync= 'reset'; |
drop table t1; |
Result
ERROR 70100: Query execution was interrupted
|
show warnings;
|
Level Code Message |
Error 1317 Query execution was interrupted
|
Error 1065 Query was empty
|
Error 1033 Incorrect information in file: './test/t1.frm' |
Expected
ERROR 70100: Query execution was interrupted
|
show warnings;
|
Level Code Message |
Error 1317 Query execution was interrupted
|
Error 1065 Query was empty
|
The .frm is not corrupted: the query was killed while the table was being opened. ER_NOT_FORM_FILE must not be reported.
Notes
Expressions of virtual columns, DEFAULT and CHECK constraints are parsed from the .frm each time a new TABLE instance is created: open_table_from_share() calls parse_vcol_defs(), which calls unpack_vcol_info_from_frm(), which calls parse_sql(). Lex_input_stream::lex_one_token() checks thd->killed on each token, calls send_kill_message() and returns END_OF_INPUT, so the parse fails. unpack_vcol_info_from_frm() does not set *error_reported when parse_sql() fails, so open_table_from_share() sets OPEN_FRM_CORRUPTED and open_table_error() raises ER_NOT_FORM_FILE.
The main error stays the kill error, ER_NOT_FORM_FILE is an extra condition. In replication it gets into Last_SQL_Error and the error log via aggregate_da_errors() when a parallel slave worker is killed (STOP SLAVE, KILL, shutdown) while opening a table.
The same code is in 10.6, 10.11, 11.8, 12.3 and main.
Suspected, not reproduced: if the kill comes between tokens where the already read part is a valid expression (e.g. after `a` in `a` + 1), the grammar accepts END_OF_INPUT and parse_sql() succeeds, because the kill error is not fatal. The TABLE is then opened with a truncated expression and may be returned to the table cache.
Attachments
Issue Links
- is caused by
-
MDEV-37938 very long query cannot be killed quickly
-
- Closed
-