detection of 'flush tables with read lock' in php
Posted
by theduke0
on Stack Overflow
See other posts from Stack Overflow
or by theduke0
Published on 2010-03-30T10:52:38Z
Indexed on
2010/04/06
22:43 UTC
Read the original article
Hit count: 172
I would like to know from my application if a myisam table can accept writes (i.e. not locked). If an exception is thrown, everything is fine as I can catch this and log the failed statement to a file. However, if a 'flush tables with read lock' command has been issued (possibly for backup), the query I send will pretty much hang out forever.
If one table is locked at a time, insert delayed works well. But when this global lock is applied, my query just waits.
The query I run is an insert statement. If this statement fails or hangs, user experience is degraded. I need a way to send the query to the server and forget about it (pretty much).
Does anyone have any suggestions on how to deal with this?
-set a query timeout?
-run asyncronous request and allow for the lock to expire while application continues?
-fork my php process?
Please let me know if I can provide and clarification or details.
© Stack Overflow or respective owner