-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Killing connections needs cooperation from the to-be-killed connection #24031
Comments
This is important in the case of I assume the fix is to have some idle loop to check if the connection is killed. |
/severity major |
I tried 4.0.12 and that version behaves the same. |
Besides what @morgo says this also makes the kill command seem less reliable reducing the trust users may have in the product. |
Running version 5.7.25-TiDB-v5.0.0, kill query just does not work on alter statement.
|
This looks like it is killing the connection after the first interaction after the running query and not directly stop the query as expected. |
I think this is a different issue, which is that the query being killed is DDL (which runs on the DDL owner, the state in the processlist here is just polling the progress of DDL). Try killing For killing DDL, there is |
|
I've forked the KILL DDL issue to #24144 |
I took a look at this today. The issue is as described; killing a connection sets My suggestion to fix it is the following:
Lines 933 to 951 in 0c72834
We have a similar problem with the sleep function, which handles interuption by looping: tidb/expression/builtin_miscellaneous_vec.go Lines 336 to 355 in 0c72834
|
Hi @morgo
Is it better to set the timeout to `NOW'? I saw some codes with a similar purpose as a workaround to interrupt the blocking read from the connection: |
Modifying
|
@djshow832 context the straightforward(and 'gopher') way. I've checked the code and looks 'cancels the context' is applicable: Line 929 in e3e1fb9
|
Cancel is problematic, because there are many concurrent executor and they may not handle the cancel welll, result in resource leak or even query block. |
I have a internal document why cancel doesn't work https://docs.google.com/document/d/1vnc2fsUkE_j0755-247lZL_KtD0FkZLEMe1ULX4p7iI/edit# And that's why we check the killed flag |
I see, thanks for the explaination. |
@tiancaiamao So I think setting |
After an internal discussion, finally we decide to filter out killed connections when doing show processlist. This will keep the same behaviour as v4.0.10 and before. |
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label. |
@morgo I will make it as 'enhancement' since the current behavior is expected. We can still keep this issue open as a backlog. |
) (pingcap#29212)" This reverts commit 52c6890.
need cherry pick to all historical versions |
Bug Report
1. Minimal reproduce step (Required)
mysql --host 127.0.0.1 --port 4000 -u root -p
SHOW PROCESSLIST
and get the connection ID of the other connection (mysql
reports its own connection id when starting up)KILL TIDB CONNECTION <id>
where ID is the connection ID of the other connection.SHOW PROCESSLIST
again.Note that this is with a single
tidb
node.2. What did you expect to see? (Required)
The killed connection gone from the processlist.
3. What did you see instead (Required)
The other connection still being in the processlist until it tries to run a query.
Once a query like
do 1
is attempted on connection B the connection is gone from the processlist and connection B showsERROR 2013 (HY000): Lost connection to MySQL server during query
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: