1041
MySQLERRORNotableServerHIGH confidence

Out of resources when opening file

Production Risk

High — table access fails; workload is blocked.

What this means

ER_OUT_OF_RESOURCES (1041, SQLSTATE HY000) is raised when MySQL cannot open a file because the OS file descriptor limit has been reached.

Why it happens
  1. 1OS open file descriptor limit (ulimit -n) is too low for the workload
  2. 2Too many tables open simultaneously exceeding table_open_cache
  3. 3MySQL data directory has too many table files
How to reproduce
trigger — this will error
trigger — this will error
-- No single trigger SQL; occurs under heavy concurrent table access

expected output

ERROR 1041 (HY000): Out of resources when opening file './db/tablename.ibd' (Errcode: 24 - Too many open files)

Fix

Increase the OS file descriptor limit

WHEN Errcode 24 (too many open files) appears.

Increase the OS file descriptor limit
-- In /etc/security/limits.conf:
-- mysql soft nofile 65535
-- mysql hard nofile 65535
-- Also set in my.cnf:
-- open_files_limit = 65535

Why this works

MySQL needs one file descriptor per open table file; raising the OS limit allows more tables to be open simultaneously.

What not to do

Set table_open_cache to an extremely large value without raising open_files_limit

table_open_cache determines how many file descriptors MySQL tries to keep open; it must not exceed the OS ulimit.

Sources
Official documentation ↗

MySQL 8.0 — 1041 ER_OUT_OF_RESOURCES

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors