I need to get a PHP app to detect when it’s MySQL database is in readlock, and throw an error message. Easy, but is there any MySQL command we can run to check current lock state, rather than just having the system get stuck, as the query is queued for the unlock?
Edit: The database is being put in readlock by the DBA, but our client wants the application to automatically handle this suituation… I’ve not found anything whilst going through the docs, hence asking the experts 🙂
After checking the docs there doesn’t appear to be a way of doing this through PHP’s mysql C API
You can review detected deadlocks by running “SHOW ENGINE [EngineName] STATUS” replacing engine name with INNDOB, MyISAM or whatever engine the locked table is running.
You can also get lock information by running “mysqladmin debug” from a command line
People have requested a SHOW LOCKS command but it doesnt exist as yet.
This is all I can establish from the docs. I’m hoping someone else has a solution for this, as it could be very useful to me.