Setting query timeout for MySQL and Ingres
Posted: Fri Jan 13, 2006 4:01 am
Greetings,
I have a PHP script that connects to an Ingres database, runs a query (or queries) and then connects to a MySQL database and runs a subsequent query or queries.
Occasionally, owing to queries that other users are running on Ingres and MySQL, the tables that I'm trying to query are locked. Consequently, the script just hangs until the tables are unlocked.
set_time_limit() cannot be used as the PHP manual states:
The SET seems to be issued without error, but the timeout never seems to fire, even when the tables are locked
Can anyone suggest a way in which I can force the Ingres and MySQL queries to timeout if they take longer than a specified time to execute?
Thanks
I have a PHP script that connects to an Ingres database, runs a query (or queries) and then connects to a MySQL database and runs a subsequent query or queries.
Occasionally, owing to queries that other users are running on Ingres and MySQL, the tables that I'm trying to query are locked. Consequently, the script just hangs until the tables are unlocked.
set_time_limit() cannot be used as the PHP manual states:
For Ingres, I've tried issuing the following SET prior to running the queries:The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
Code: Select all
$link = ingres_connect($dbname, $user, $pass) or die("Could not connect");
$sql = "set lockmode session where readlock = nolock, timeout = 1";
ingres_query($sql) or die('problem setting timeout');Can anyone suggest a way in which I can force the Ingres and MySQL queries to timeout if they take longer than a specified time to execute?
Thanks