Re: signal handling in mysql cli
- Date: Wed, 10 Dec 2014 11:30:51 +0100
- From: Sebastien FLAESCH <sf@xxxxxxx>
- Subject: Re: signal handling in mysql cli
Nobody concerned by this case?
Simple question: is it safe or not to do a KILL QUERY in a SIGINT signal handler?
On 12/03/2014 05:25 PM, Sebastien FLAESCH wrote:
I have a similar question regarding KILL QUERY usage:
We have a C client program using libmysqlclient.so, it is a single-threaded program.
When running a long query, how can I send the KILL QUERY command when a SIGINT (CTRL-C)
is caught? (of course we implement a signal handler, so we keep the control)
=> Is is safe to establish a new connection to the server in the signal handler, using
mysql_init() + mysql_real_connect(), and execute the KILL QUERY with the mysql thread
id I got from the initial mysql_init() / mysql_real_connect()?
I made some tests, and it seems to work fine, the long query returns SQL error -1317:
"Query execution was interrupted" (which is expected)
We want to support SQL interruption properly, so please someone from the dev team,
give me a clear answer... I don't want to use a side effect or undocumented feature.
Doing all this stuff in a signal handler is certainly risky... no?
I could not find the information in the documentation (mysql_real_connect).
I wish there would be an API like mysql_cancel_query(), similar to Oracle's OCI
On 12/02/2014 05:13 PM, walter harms wrote:
when i use CTRL-C to break a query that works fine in interactive mode.
mysql> select sleep(10) ;
^CCtrl-C -- sending "KILL QUERY 24289" to server ...
Ctrl-C -- query aborted.
| sleep(10) |
1 row in set (0.86 sec)
but when i use the noninteractive mode
timeout 5 mysql -BAN -e "select now(); select sleep (100) ; select now() "
i looks like that but "show full processlist;" shows otherwise and that is true
as a list of long running querys showed.
Is there a way to make it behave like the interactive version ?
Now it is a bit confusing for everyone.
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql