I have a few automated scripts that access a database table, sometimes locking it in the process. One of these is a multithreaded daemon process that loops infinitely, performing tasks dictated by records in the database. Occasionally, one of the less frequent processes locks up a particular db table and the daemon process has its db connection timeout, causing the script to crash. I'm hoping to fix the script so that it will be a bit more robust, but I would also like to make it more patient when the database is busy. That is to say I want to make the script very tolerant of slow behavior from the db server. I.e., I want to increase the timeout for queries.
I'm using PDO/MySQL to access the database and as best I can tell, PDO::ATTR_TIMEOUT seems to be the value I'm interested in. Do I have that right? The docs are really vague about what this value means.
Anyways, it appears to have a default value of 2 seconds -- which seems really short. Having watched the log file while my script was experiencing such a crash, it seemed to me that the timeout was considerably longer -- e.g. 30 seconds or so.
Also, the docs are very vague on the parameters available for the various PDO drivers. The 4th parameter of PDO::__construct is for $driver_options but the docs otherwise give no detail, simply saying that it is:
A key=>value array of driver-specific connection options
The MySQL-specific PDO page doesn't mention any timeout-specific values nor does it indicate whether one might use these driver-specific options in the $driver_options array.