[Sqlrelay-discussion] ping() sendQuery() problem during database failure handling
Brought to you by:
mused
|
From: Kumara S <kum...@si...> - 2006-01-20 10:26:00
|
Hi, We are develpoping a web application that connects to MySQL thru sqlrelay... We thought of using PHP pear DB classes to abstract the database. My requirement is to connect to the database server and check if it can handle further queries successfully. When the MySQL server goes down, sqlrelay sendQuery() keeps retrying infinitely and returns only after the DB comes up. Since i can't allow my page to wait till everything becomes normal, i thought of using ping() to check the status of MySQL before querying. but, even when the DB recovers later, ping() returns false. Following ealier discussions with Maciej Wisniowski, ping() just gives the status of the connection that went to CLOSE_WAIT state and does not attempt to reconnect to DB. It is only the first sendQuery that reconnects. So, using ping() before sendQuery() does not allow my application to recover even when MySQL is up. Calling sendQuery() directly sends my application to infinite loop in case of DB failure. The problem is simple. Connect to DB when it is available in a single try, return false in case of a DB failure. API calls like mysql_connect gives me just that. but, sqlrelay either gives me infinite retries(when DB goes down) or no try at all (when it recovers). Please give me a workaround. Thanks! Kumara Sundaram |