MySQL cannot acquire an operating-system file lock, blocking table or index operations.
MySQL Error 10: EE_CANTLOCK signals that the server failed to obtain an OS-level file lock on the target table or index file. Check for another process holding the lock, confirm file permissions, and retry the statement after releasing the conflicting lock to resolve the issue.
Can't lock file (OS errno %d - %s)
MySQL throws Error 10 with condition name EE_CANTLOCK when it cannot secure an operating-system lock on a table’s .MYI, .MYD, .ibd, or redo file. The error text is "Can't lock file (OS errno %d - %s)" where %d and %s come from the host OS.
The lock attempt happens before read or write operations.
MySQL aborts the statement to keep data consistent, so applications see a failure instead of silent corruption.
Error 10 is common on busy hosts where multiple MySQL instances, backup tools, antivirus software, or rogue scripts hold open file descriptors.
It also appears after crashes when stale .pid or .lock files remain.
Network filesystems like NFS and SMB add latency that makes lock acquisition unreliable, triggering the same error even with no visible contention.
Repeated EE_CANTLOCK stops DML and DDL, causing application timeouts and data loss risk.
Long-running locks can escalate into deadlocks, replica lag, or failed backups.
Rapid diagnosis preserves uptime, keeps replication in sync, and maintains SLA commitments.
The primary trigger is another process already holding an exclusive or shared lock on the same file.
Incorrect file permissions, SELinux policies, or read-only media also block MySQL from locking.
Filesystem issues like inodes at capacity or disk errors return low-level OS codes that propagate up as EE_CANTLOCK.
First, identify the blocker with lsof or fuser, then terminate or pause that process. Verify the MySQL user owns the data directory and has rw permissions.
If locks remain, restart MySQL during a maintenance window to clear stale descriptors.
For network filesystems, switch to local storage or enable NFS locking (lockd, statd). On Linux, confirm /proc/locks shows no orphaned entries.
Scenario: Backup program reading .ibd files. Solution: Configure xtrabackup or mysqldump with --lock-wait-timeout or run during low traffic.
Scenario: Second MySQL instance started accidentally.
Solution: Kill duplicate mysqld process and remove its pid file.
Use a single MySQL service per data directory. Schedule backups via orchestrated jobs that request FLUSH TABLES WITH READ LOCK when needed.
Enable proper umask and SELinux contexts on the datadir.
Monitor /proc/locks and MySQL error log via Galaxy alerts to catch lock buildup early.
Error 102 (ER_LOCK_WAIT_TIMEOUT) indicates row-level wait rather than file-level; increase innodb_lock_wait_timeout or optimize queries.
Error 35 (ER_CANT_CREATE_FILE) arises when MySQL cannot create the file at all; free disk or fix permissions.
.
No. Any process that opens the file with incompatible flags, including backup tools or editors, can hold the lock.
Only when you are absolutely sure no mysqld is running. Otherwise delete may corrupt data.
It may let MySQL start after a crash but does not solve external lock contention. Use only for emergency recovery.
Galaxy’s query history and runtime metrics alert you when statements fail with EE_CANTLOCK, so you can react before users notice.