Common SQL Errors

MySQL Error 11: EE_CANTUNLOCK – Can't unlock file – How to Fix and Prevent

Galaxy Team
August 5, 2025

MySQL cannot release a file lock on a table because the operating system reports the resource is still busy.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 11 EE_CANTUNLOCK?

MySQL Error 11: EE_CANTUNLOCK happens when the server cannot release a file lock on a table. Close competing processes, ensure local storage, and restart MySQL to clear lingering locks.

Error Highlights

Typical Error Message

Can't unlock file (OS errno %d - %s)

Error Type

File System Error

Language

MySQL

Symbol

EE_CANTUNLOCK

Error Code

11

SQL State

Explanation

Table of Contents

What is MySQL Error 11 EE_CANTUNLOCK?

MySQL raises "Can't unlock file (OS errno 11 - Resource temporarily unavailable)" when it cannot release a file lock on a table’s .frm, .ibd, or .MYD/.MYI file. The operating system signals that another process still holds the lock, blocking MySQL from finishing the current statement.

This global error can surface during INSERT, UPDATE, SELECT ... FOR UPDATE, ALTER TABLE, or replication events.

It is common on shared or networked storage, under heavy concurrency, or when antivirus or backup software touches MySQL data files. Resolving the conflict quickly restores database availability and protects data integrity.

What Causes This Error?

Lingering file locks from crashed clients or killed threads keep the table busy, so MySQL cannot unlock it.

External processes such as rsync, antivirus scans, or backup agents may open the file with exclusive or shared locks, preventing MySQL from releasing its own.

Network file systems (NFS, SMB, EFS) introduce higher lock-manager latency. If lock requests time out, MySQL retries and eventually emits EE_CANTUNLOCK.

High-concurrency workloads on InnoDB can also exhaust the lock table, causing failed unlock attempts.

How to Fix MySQL Error 11: EE_CANTUNLOCK

First, identify the operating-system process that owns the blocking lock with lsof +D /var/lib/mysql or fuser -v. If it is non-MySQL, stop or pause it. If it is a defunct MySQL thread, restart the server to clear the handle.

Move data off network storage to local disks when possible. Increase innodb_open_files and verify open_files_limit is well above the total number of tables.

Use short transactions to release locks promptly and avoid long-running ALTER statements at peak load.

Common Scenarios and Solutions

Backup program holds lock: Pause the backup, flush tables, and retry the query.

NFS share latency: Mount with nolock when safe or migrate to local SSD storage.

Un-killed session in processlist: Execute KILL CONNECTION <id> then run FLUSH TABLES.

Best Practices to Avoid This Error

Configure backups to use MySQL-native mechanisms (mysqldump, mysqlpump, Percona XtraBackup) instead of file-level copies.

Keep innodb_flush_method set to O_DIRECT on Linux to reduce kernel lock contention.

Monitor performance_schema.file_summary_by_instance for long waits. In Galaxy, enable query history and lock-wait visualizations to spot problematic code paths early.

Related Errors and Solutions

MySQL Error 9: EE_BADF – bad file descriptor. Usually indicates closed file handle; restart threads.

MySQL Error 12: EE_OUTOFMEMORY – memory allocation failed. Tune innodb_buffer_pool_size.

MySQL Error 13: EE_CANTCREATE – cannot create file. Check permissions and disk space.

.

Common Causes

Lingering Locks After Crash

A previous mysqld instance crashed while holding a table lock.

The OS keeps the lock until reboot or manual release.

External Process Holding File

Backup, antivirus, rsync, or manual copy commands open the data file with a lock, blocking MySQL's unlock call.

Network File System Latency

Lock requests to NFS/SMB file servers time out or are delayed, so MySQL cannot complete UNLOCK before the internal timer expires.

Exhausted File Handles

If open_files_limit is too low, MySQL may fail to reopen a file to unlock it, returning EE_CANTUNLOCK.

.

Related Errors

FAQs

Does EE_CANTUNLOCK damage my tables?

No data corruption is recorded. The error aborts the current statement, but storage engines keep consistency.

Is a server restart always required?

Only if external processes cannot be stopped or the lock belongs to a zombie MySQL thread. Most cases clear with FLUSH TABLES.

Can I ignore the error in replication?

Ignoring will cause replication lag or stops. Fix on the source and restart the replica IO thread.

How does Galaxy help?

Galaxy surfaces lock waits in real time, lets teams kill blocking sessions from the editor, and shares root-cause notes in Collections.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo