tags:

views:

28

answers:

1

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.

A: 
SHOW OPEN TABLES LIKE "table_name";

Gives you results something like:

database, table, in_use, name_locked
test, my_table, 1, 0

The 'in_use' column will tell you if someone else has a read/write lock on that table.

J Jorgenson