Software⏱️ 2 min read📅 2026-05-30

How to Fix: Getting "Lock wait timeout exceeded; try restarting transaction" even though I'm not using a transaction

MySQL Lock wait timeout exceeded error when not using transactions.

Quick Answer: Check for table locks, use EXPLAIN to identify potential bottlenecks and optimize queries.

The error 'Lock wait timeout exceeded; try restarting transaction' in MySQL can be confusing, especially when you're not using transactions. There are several reasons why this could happen even without a transaction. One of the main causes is the use of locking mechanisms such as row-level locks or table-level locks, which can cause contention between concurrent queries.

💡 Why You Are Getting This Error

  • [Cause]

🔧 Proven Troubleshooting Steps

Method 1: Table Locks

  1. Step 1: Check if the table is locked by another process or thread. You can use the 'SHOW ENGINE INNODB STATUS' command to check for any locks.

Method 2: Row-Level Locks

  1. Step 1: Check if the update statement is updating a large number of rows. This can cause contention and lead to lock wait timeouts.

Method 3: Optimizing Queries

  1. Step 1: Optimize your queries to reduce contention and locking. Consider using indexes, rewriting your queries, or splitting the update into smaller chunks.

🎯 Final Words

To avoid lock wait timeouts in MySQL, it's essential to identify and address the root cause of contention. By following these steps, you can reduce locking and improve overall performance.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions