We had some slowness in our application. When I checked I figure out that one particular table was locked so all transactions were rejected by Lock wait timeout exceeded
. When I did SHOW PROCESSLIST;
I was expecting to see some processes with Waiting for table level lock
state but it shows nothing !? only some queries INSERT/UPDATE on the same table taking exactly 120 seconds before time-out and others processes on sleeping state (see picture):
MariaDB Locking – Troubleshooting Locked Table When SHOW PROCESSLIST Shows Nothing
innodblockingmariadb
Related Question
- MySQL InnoDB – Primary Key Locking on Delete in READ COMMITTED
- Mysql – InnoDB row level locks without SELECTs
- SQL Server Locking – Detecting Locked Table or Row in SQL Server
- MariaDB – Which Table Will Get Locked with This Query
- MySql timeouts waiting for table lock, no apparent deadlocks
- Reduce Time Acquiring MongoDB Schema Lock – MongoDB 4.0
- Locking and Blocking – Does a Lock Mean a Wait?
Best Answer
The reason in my case was that one transaction is making a read-lock on a particular table leading to a "
Lock wait timeout exceeded
" because its not committed. So all other transactions are waiting to that particular tranx to do commit.Now, why
SHOW PROCESSLIST;
show nothing ? In fact, it does. you'll find it (the process) with a "Sleep" state and with no query shown in the info column like if it's just a regular connection to the database.Let's check my example in the image :
In Blue, those are some very simple queries blocked (taking 120 second before a time-out) and the red one is the "ghost" or non-committed transaction.
To see those kind of transactions execute :
And you may kill the process
kill <id>;
in whichTRX_QUERY
is null to free other transactions. In my case,KILL 33267342;
Make sure to check the non-committed transaction to see if a
commit;
or aRollback
clause is missing in order to ovoid such issues.