SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

October 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

Solving the “SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded” Issue

The SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction error is a common issue that occurs when your application is trying to acquire a lock on a database record for too long. This usually happens due to inefficient queries or high traffic causing long-running transactions.

Understanding the Error

The error message indicates that the MySQL server has been waiting for a lock on a table for an extended period, which exceeds the configured innodb_lock_wait_timeout value. When this limit is reached, the transaction is automatically rolled back, and the error is thrown.

Analyzing the Stack Trace

Let’s break down the provided stack trace to identify the root cause of the issue:

  • Line 17: The error originates from the PDO extension for MySQL (Varien_Db_Statement_Pdo_Mysql.php) during statement execution.
  • Lines 2-16: The trace shows that the error propagated up through the Magento framework, indicating it’s likely related to a core function.

Common Causes and Solutions

Slow Queries

The most common reason for this error is slow-running queries, especially when they involve complex joins or large data sets. To diagnose this:

  1. Enable MySQL query logging by adding log to the general log file (my.cnf):

    [mysqld]
    log
    
  2. Analyze the logs for any long-running queries during the time of the error.

Inadequate Database Configuration

If your application is experiencing high traffic, you might need to optimize your database configuration:

  1. Check that innodb_lock_wait_timeout in my.cnf is appropriately set (default is 50 seconds).

  2. Ensure sufficient memory allocation for MySQL buffers using the --innodb-buffer-pool-size parameter.

  3. Consider adding read replicas or sharding your data across multiple databases to distribute load.

Poor Database Design

Inefficient database design can also contribute to this issue:

  1. Identify and eliminate any circular foreign key references that could cause long lock chains.

  2. Ensure proper indexing on relevant columns in the affected tables (https://laravelcompany.com/blog/database-indexing-best-practices).

Best Practices for Preventing Future Occurrences

Use Optimized Queries

  • Avoid SELECT * queries; specify only required fields.
  • Limit result sets using LIMIT if fetching large data sets is not necessary.

Implement Indexing Strategically

Index your tables wisely to speed up query performance (https://laravelcompany.com/blog/sql-indexes-explained).

Use Batch Processing

For long-running tasks, consider breaking them into smaller batches processed separately. This reduces the lock duration significantly.

Conclusion

The SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded issue is typically caused by slow queries or high database load during peak traffic periods. By enabling logging, optimizing your database configuration, and following best practices for query optimization and database design, you can minimize the occurrence of this error in your application.

If you’re facing persistent issues, consider consulting with a professional database administrator or reaching out to our team at Laravel Company for expert guidance.

Magento 1 Database Performance API

Our network