ERROR 1206 occurs when InnoDB exhausts the lock table buffer space during large transactions or high-concurrency operations. The primary fix is increasing innodb_buffer_pool_size, though breaking large operations into smaller batches provides a quick workaround.
This error indicates that the InnoDB storage engine has run out of memory allocated for managing row locks. InnoDB stores lock tables within the innodb_buffer_pool_size allocation, and when you perform operations that affect many rows (such as bulk updates, deletes, or large inserts), the lock memory can become exhausted. By default, MySQL allocates only 128MB for this buffer pool, which is insufficient for most real-world applications performing large transactions. The error commonly occurs during: - Importing large data files (multi-gigabyte loads) - Bulk deletion of tens of thousands of rows with cascading constraints - CREATE TABLE...SELECT operations with full-table locks - High-concurrency scenarios where multiple connections lock overlapping row ranges - Long-running transactions holding many locks simultaneously
Run this query to see your current buffer pool allocation:
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';Note the value (typically shown in bytes). If it's less than 1GB on a production server, it's likely too small.
Edit your MySQL configuration file (/etc/my.cnf, /etc/mysql/my.cnf, or /etc/mysql/mysql.conf.d/mysqld.cnf depending on your system):
[mysqld]
innodb_buffer_pool_size = 2GFor a dedicated database server, allocate 50-80% of available RAM. For shared systems, start with 1-2GB and monitor memory usage.
Common sizing:
- Development: 256MB-512MB
- Small production: 1-2GB
- Medium production: 4-8GB
- Large production: 16GB+
After editing, restart MySQL:
sudo systemctl restart mysql
# or
sudo service mysql restartAfter restarting, confirm the new buffer pool size:
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';The value should now match your configuration change.
If you cannot restart MySQL immediately, refactor your operation to process rows in chunks. Instead of:
UPDATE large_table SET status = 'inactive' WHERE created_at < '2020-01-01';Use a loop with LIMIT:
SET @batch_size = 10000;
WHILE EXISTS (
SELECT 1 FROM large_table
WHERE created_at < '2020-01-01'
LIMIT 1
) DO
DELETE FROM large_table
WHERE created_at < '2020-01-01'
LIMIT @batch_size;
COMMIT;
END WHILE;In application code (Python example):
batch_size = 10000
while True:
cursor.execute(
"DELETE FROM large_table WHERE created_at < %s LIMIT %s",
('2020-01-01', batch_size)
)
rows_deleted = cursor.rowcount
db.commit()
if rows_deleted == 0:
breakThis releases locks frequently, preventing lock table exhaustion.
For SELECT operations on read-uncommitted data, temporarily reduce the isolation level:
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM large_table WHERE condition;This avoids gap locks on range scans, reducing lock memory usage. Use only when dirty reads are acceptable.
If the table has undergone many delete/truncate operations, fragmentation may require more locks. Rebuild it:
ALTER TABLE large_table ENGINE=InnoDB;This reclaims wasted space and may reduce lock requirements. Warning: This is a blocking operation on large tables.
Multiple Buffer Pool Instances: On systems with large buffer pools (>1GB), split the buffer into multiple instances to reduce contention:
[mysqld]
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8InnoDB Row-Level Locking vs Table Locks: This error is specific to InnoDB's row-level locking. MyISAM tables use table-level locks and won't encounter this error, though they have different concurrency limitations.
Monitoring Lock Memory: Use Performance Schema to monitor lock usage:
SELECT * FROM performance_schema.memory_summary_global_by_event_name
WHERE EVENT_NAME LIKE '%innodb_lock%';Production Impact: Buffer pool size changes require a restart. Plan this during maintenance windows. For zero-downtime adjustments on MySQL 5.7+, consider using a replica: resize the replica's buffer pool, promote it to primary, then demote and resize the old primary.
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL