Bug #104250 kill query will case some mysql client block

Submitted: 8 Jul 2021 6:47 Modified: 16 Jul 2021 13:12
Reporter: deng yl (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.25 OS:Any
Assigned to: CPU Architecture:Any

[8 Jul 2021 6:47] deng yl
Description:
at sometimes the kill query will case some mysql client block.

conn1 (use mysql client) to execut a muilt-statment;
conn2 (use mysql client) kill query conn1;
the conn1 may block for read mysqld response.

The conn1 block reason is that the kill query happen at the muilt-statment one statement have finsh and the next statement not start, the packet response to the
client have finsh with ok and SERVER_MORE_RESULTS_EXISTS status also in the packet. And at the THD::send_kill_message() the get_stmt_da()->is_set() will be true, so the packet with ok and SERVER_MORE_RESULTS_EXISTS will response to the client, but this query is interrupt, no more messages will be responsed. But the client will wait next response message.

How to repeat:
1.add this code at sql_parse.cc:1856 before the 'while (!thd->killed && (parser_state.m_lip.found_semicolon != nullptr) &&'
    
```
      DBUG_EXECUTE_IF("test_muilt_statement_error", {
        thd->killed = THD::KILL_QUERY;
      });
``` 
2.make with the debug and make install

3.use the mysql to login;
mysql> create database test;
Query OK, 1 row affected (0.14 sec)

mysql> use test;
Database changed

mysql> create table t1(c1 int, c2 int);
Query OK, 0 rows affected (0.09 sec)

mysql> SET @@session.debug="+d,test_muilt_statement_error";
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter //
mysql> insert into t1 values(1, 1);
    -> insert into t1 values(2, 2);
    -> //
Query OK, 1 row affected (0.02 sec)
....block
[16 Jul 2021 13:12] MySQL Verification Team
Hello deng yl,

Thank you for the report and test case.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.