Is there a way to tell whether a table or a table row is being used in a transaction at the current moment by another session?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can actually view outstanding row locks in transactions with SHOW ENGINE INNODB STATUS if you enable the lock monitor, but you’ll need to parse the results to get anything usable. These locks are usually only momentary. They disappear after the transaction is committed.
If you’re trying to serialize your queries, you can implement table locking (for a whole table), or (with InnoDB) row level locking using SELECT … LOCK IN SHARE MODE (or you can let MySQL do this for you with the SERIALIZABLE isolation mode).
You can even come up with your own locking scheme using values stored in the database, which I’ve seen many implement.
The default innodb_lock_wait_timeout is 50 seconds and applies to all row level locks in InnoDB. There is no lock wait timeout for table locks.
If you’re more specific, such as providing an actual scenario and the desired behavior, we’ll be able to answer in more detail.