How to Configure fs.aio-max-nr for MySQL InnoDB to Prevent AIO Slot Errors
The article explains why MySQL may fail to start when the number of required AIO event slots exceeds the system's fs.aio-max-nr setting, demonstrates how to observe the slots with strace, and provides formulas and recommendations for configuring fs.aio-max-nr in single‑ and multi‑instance deployments.
MySQL enables innodb_use_native_aio by default, using asynchronous I/O. When the number of AIO slots required at startup exceeds the system's fs.aio-max-nr value, MySQL cannot start and reports InnoDB: io_setup() failed with EAGAIN after 5 attempts.
In a single‑instance environment this issue is rare, but it becomes common when deploying multiple MySQL instances on the same host.
The article analyzes how to configure the fs.aio-max-nr parameter.
About aio-nr and aio-max-nr
aio-nr is the running total of the number of events specified on the io_setup system call for all currently active aio contexts. If aio-nr reaches aio-max-nr then io_setup will fail with EAGAIN. Note that raising aio-max-nr does not result in the pre‑allocation or re‑sizing of any kernel data structures.How many event slots does MySQL allocate on startup?
Using strace to trace io_setup calls:
strace -fe trace=io_setup /path/to/mysqld --defaults-file=/etc/my.cnf --daemonize 2>&1 | grep io_setupThe observation shows a total of 4709 slots, calculated as 18 * 256 + 101 .
Each InnoDB I/O thread allocates 256 event slots.
Conclusion
For each instance, fs.aio-nr = (innodb_read_io_threads + innodb_write_io_threads + log thread + insert buffer thread) * 256 + 101 .
If deploying a single instance, fs.aio-max-nr should be greater than the instance's fs.aio-nr .
If deploying multiple instances, fs.aio-max-nr must be greater than the sum of fs.aio-nr for all instances on the host.
Images in the original article illustrate the slot distribution and provide additional visual context.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.