MySQL cannot close a file descriptor after writing, usually due to file-system, permission, or hardware problems.
MySQL Error 1023: ER_ERROR_ON_CLOSE signals that the server failed to close a table, log, or temporary file. Check disk space, file permissions, and operating-system error logs; then repair or move the affected files to clear the error.
Error on close of '%s' (errno: %d - %s)
Error 1023 appears as: ERROR 1023 (HY000): Error on close of '%s' (errno: %d - %s)
. MySQL reports it when the operating system returns an error while the server tries to close a file descriptor for a table, log, or temporary file.
The condition usually points to a file-system problem such as insufficient space, missing permissions, or a damaged disk.
Fixing it quickly prevents data loss and avoids server shutdowns.
The server raises ER_ERROR_ON_CLOSE when the close()
system call fails. MySQL surfaces the OS errno
and message, letting you trace the root cause directly to file-system issues, quota limits, or hardware faults.
Affected operations include ALTER TABLE
, large inserts, log rotation, and temporary table flushes.
If MySQL cannot close its file handle, it may mark the table as crashed and block subsequent queries.
Identify the failing filename in the error, then inspect the corresponding directory. Confirm available disk space with df -h
, file descriptors with lsof
, and permissions with ls -l
. Correct any anomalies and restart the server only if necessary.
Run CHECK TABLE
or REPAIR TABLE
on MyISAM tables, or ANALYZE TABLE
for InnoDB.
If the file is beyond repair, rename or move it out of the data directory so MySQL can recreate it on startup.
Disk full errors often accompany ER_ERROR_ON_CLOSE. Free space or mount a larger volume, then retry the query. Permission issues arise after manual file copies; reset ownership to the MySQL user.
On network file systems, intermittent IO failures can trigger the error.
Move the data directory to local storage or tune NFS options for stability.
Monitor disk usage, inode counts, and open file descriptors. Configure ulimit -n
high enough for busy servers.
Schedule log rotations off-peak to reduce contention.
Using Galaxy’s desktop SQL editor, you can store vetted maintenance queries such as disk-usage checks in shared Collections, ensuring every engineer can diagnose and resolve file-system issues swiftly.
Errors 23 (ERRNO 23 - File table overflow) and 24 (ERRNO 24 - Too many open files) often precede 1023.
Increasing open_files_limit
and OS file-handle limits resolves them.
Error 1016 (HY000 - Can't open file) indicates MySQL cannot open rather than close a file. Causes and fixes overlap but focus on access permissions.
.
No free space or exhausted inodes prevent MySQL from closing and flushing file buffers.
Files created manually or restored from backups may not belong to the MySQL user, blocking close operations.
Bad sectors, failing SSDs, or corrupted ext4/XFS metadata cause kernel errors returned to MySQL.
NFS timeouts or SMB disconnects interrupt close() calls on remote storage.
Hitting OS or MySQL open_files_limit
keeps descriptors in limbo, making subsequent close attempts fail.
.
Usually no, but it can mark MyISAM tables as crashed. Run CHECK TABLE or restore from backup to be safe.
Ignoring it risks sudden crashes or data loss. Always resolve the root file-system cause quickly.
Only if MySQL hangs or you moved corrupted files. Otherwise fix permissions, free space, and issue FLUSH TABLES.
Galaxy lets teams store, version, and share maintenance queries. Everyone can quickly run disk and table-health checks without hunting for scripts.