Fail the fio job instead of hanging when out of open files #207

Open
koolkhel wants to merge 2 commits from koolkhel/vitastor:fio-out-of-fds into master
Contributor

Description

A fio job whose client runs out of file descriptors retries its OSD connections forever (on_connect_peer() re-arms the peer_connect_interval timer on EMFILE), so its I/O never completes and fio hangs with no error. Every fio job has its own client, which keeps one socket per OSD it has sent I/O to, so a large image on a cluster with more than about 1000 OSDs is enough at the usual soft limit of 1024.

When ops are in flight, nothing has completed for 30 s, and the process cannot open even /dev/null (EMFILE/ENFILE), the engine now fails the job with EMFILE. It also prints one line with the soft and hard limits and the remedy:

vitastor: nothing completed for 30 s and no file descriptor is left (Too many open files), open files limit: soft 15, hard 524288. Each job keeps a connection to every OSD it writes to: raise ulimit -n.
fio: pid=..., err=24/file:.../fio_cluster.cpp:..., func=out of fds for 30s, ulimit -n 15, error=Too many open files

The same check covers the image lookup in sec_setup(): with create_serialize=0 it runs in each job after the start, so one job can use up the process's fds while another is still waiting for etcd. Ops that sec_queue() completes by itself (mirror error, read-only image) no longer stay in the in-flight count.

Only the fio engine changes; the client library still retries forever, as QEMU and the other users expect. A stall with free fds (an inactive PG, a dead OSD) keeps waiting as before, and normal runs never meet the check. There is no new option.

Neighbour PR: #202 adds a failed-client check to the same two loops in sec_getevents(). They are independent; if both are merged, both checks stay.

Found: seen in a run (hang): fio stopped making progress on a cluster of about 3800 OSDs at the default soft limit of 1024 open files. Fd exhaustion is the likely cause there, not proven. Reproduced on a 3-OSD test cluster with the soft limit lowered.

Tested: in a downstream tree whose fio engine and connect retry are the same as on master (the run above is from there): 3 OSDs, a 3/2 pool with 16 PGs. Under the lowest soft limit at which fio writes one 128K stripe, a 2 MiB write (all 16 PGs) hung until killed at 120 s without the change. With it, the job fails after 30 s with EMFILE and the message above (fio exit code 1). The same write with ulimit -n 1024 is unaffected. The second commit was re-run there as well (both units pass); the lookup path has no test of its own. This patch on master: compiled only.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description A fio job whose client runs out of file descriptors retries its OSD connections forever (`on_connect_peer()` re-arms the `peer_connect_interval` timer on EMFILE), so its I/O never completes and fio hangs with no error. Every fio job has its own client, which keeps one socket per OSD it has sent I/O to, so a large image on a cluster with more than about 1000 OSDs is enough at the usual soft limit of 1024. When ops are in flight, nothing has completed for 30 s, and the process cannot open even /dev/null (EMFILE/ENFILE), the engine now fails the job with EMFILE. It also prints one line with the soft and hard limits and the remedy: ``` vitastor: nothing completed for 30 s and no file descriptor is left (Too many open files), open files limit: soft 15, hard 524288. Each job keeps a connection to every OSD it writes to: raise ulimit -n. fio: pid=..., err=24/file:.../fio_cluster.cpp:..., func=out of fds for 30s, ulimit -n 15, error=Too many open files ``` The same check covers the image lookup in `sec_setup()`: with `create_serialize=0` it runs in each job after the start, so one job can use up the process's fds while another is still waiting for etcd. Ops that `sec_queue()` completes by itself (mirror error, read-only image) no longer stay in the in-flight count. Only the fio engine changes; the client library still retries forever, as QEMU and the other users expect. A stall with free fds (an inactive PG, a dead OSD) keeps waiting as before, and normal runs never meet the check. There is no new option. Neighbour PR: #202 adds a failed-client check to the same two loops in `sec_getevents()`. They are independent; if both are merged, both checks stay. Found: seen in a run (hang): fio stopped making progress on a cluster of about 3800 OSDs at the default soft limit of 1024 open files. Fd exhaustion is the likely cause there, not proven. Reproduced on a 3-OSD test cluster with the soft limit lowered. Tested: in a downstream tree whose fio engine and connect retry are the same as on master (the run above is from there): 3 OSDs, a 3/2 pool with 16 PGs. Under the lowest soft limit at which fio writes one 128K stripe, a 2 MiB write (all 16 PGs) hung until killed at 120 s without the change. With it, the job fails after 30 s with EMFILE and the message above (fio exit code 1). The same write with `ulimit -n 1024` is unaffected. The second commit was re-run there as well (both units pass); the lookup path has no test of its own. This patch on master: compiled only. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-29 20:06:43 +03:00
A fio job whose client runs out of file descriptors retries its OSD
connections forever, so its I/O never completes and fio hangs. When no
I/O has completed for 30 s and the process cannot open even /dev/null,
fail the job with EMFILE and name the limit to raise. The client itself
keeps retrying, as QEMU and the other users of the library expect.
koolkhel added 1 commit 2026-11-29 21:25:25 +03:00
With create_serialize=0 the image lookup runs in each job after the
start, so one job can use up the process's fds while another is still
waiting for etcd, and that job hangs before any I/O. Apply the same
check there. Also count ops that sec_queue completes by itself (mirror
error, read-only image, unknown direction) out of the in-flight count,
so it does not stay above zero.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fio-out-of-fds:koolkhel-fio-out-of-fds
git checkout koolkhel-fio-out-of-fds
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#207
No description provided.