-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Job timeout doesn't kill the mysql query #4629
Conversation
That should happen. What version of redash are you using? |
@Jakdaw |
@rauchy does the RQ implementation of cancel send Interrupt signal to the job before killing it? |
@arikfr I dig into the code and found that the RQ did send interrupt signal to the job after cancelling the job. However my case is, I didn't manually cancel the job but let the query automatically trigger the timeout exception. But the timeout handler didn't kill the sql query. |
@dingweihua thanks for reporting. I will look into the signal propagation issue for MySQL, but meanwhile - you might benefit from updating to the latest master, as it seems that your version had an implicit 180 second timeout, which is no longer imposed. |
@rauchy Yeah i got it. Thanks! You updated the latest default time limit to -1 to mention the user to setup it. |
On considering this issue, I'm trying to use version 8.0 (which uses Celery). Would the sql query be automatically killed after timeout in v8.0? @rauchy |
Testing this, it appears that MySQL is receiving signals properly on timeouts and manual cancellation using the latest |
Thanks @rauchy |
Thinking about this issue again, i found you've already set the signal processing handler in QueryExecutor's run() method. But in this situation, I don't think our thread could receive the SIGINT signal. SIGINT is translated into a KeyboardInterrupt exception. While it seems that the JobTimeoutException is not a "SIGINT" like signal. Actually, I debugged my local code (master branch). The run_query Exception was raised (in QueryExecutor.run()) while no SIGINT signal received. |
What makes you think that? I ran the following test and saw that the query was cancelled in MySQL:
Same thing with setting a short time limit with a query that times out. Are you getting different results? |
@rauchy Yes, you're right! I have the same idea on your mentioned case. But my case is different from yours. In my case, I didn't manually trigger the cancel operation. My situation is:
This is my case. In my case, I don't think we can receive the signal so we couldn't do anything on the running sql query. Do you think we should also kill the sql query after facing time limit (without manually cancelling)? |
@rauchy when a timeout is reached how the job is being cancelled? |
@dingweihua I've just double-checked this. As I said, on @arikfr on manual cancellations the work horse will receive a SIGINT and cancel as it used to (by executing the MySQL |
@rauchy I know that Postgres terminates running queries if the client disconnects, but not sure about MySQL. I'm pretty sure it doesn't (hence the explicit behavior we have). Maybe it was introduced in newer versions of MySQL? |
@dingweihua which version of MySQL are you running? |
I'm using MySQL 5.5.5-10.2.12-MariaDB |
@dingweihua I've tried this with 10.2.31 and 10.1.44 and they worked as expected. Wondering if this is dependent on the type of query you are running. In my example, I'm using |
@rauchy I've tried |
@dingweihua interesting. Can you try running with https://github.com/getredash/redash/tree/forward-timeout-signals-to-mysql? |
@arikfr WDYT about this? We'll probably need to attach to this signal to other multi-threaded runners. |
* forward timeout SIGALRMs to MySQL threads in order to kill any running proccesses * no need to attach to SIGALRM as RQ already does that # Conflicts: # redash/query_runner/mysql.py
I'm using the master branch. During refreshing one of my dashboards, a mysql query reached the timeout which raised the "query execution time limit".
I thought the timeout handler would also kill the related sql query in mysql server while it didn't. So there are lots of stuck sql queries in the mysql server.
So is that possible to also kill the related running query in the database server during handling the timeout?
Thanks.