FreeBSD 13 kernel panics from nginx (sendfile problem)


I opened a bug PR 264273 because I have two panics in 8 hours after the binary update from 12.2 to 13.0 from nginx calling sendfile.

Any one else with a similar problem?

Somebody suggested to disable sendfile and enable aio . Is this a suggested move or not?

Thank you again,
Last edited by a moderator:
Hi bigbrother, so was it solved when you binary upgraded the machine to 13.1-RELEASE?

Just curious, because I'm planning to enable sendfile on FreeBSD 13.1&NFS.
After updating to 13.1 I kept the sendfile off and everything was working perfectly. I enabled the sendfile yesterday that you posted a reply, but after 8 hours even though the system did not panic (I could ssh login to it), the web server nginx was blocked in 'D' state, not responding to queries, nothing could kill it, issuing 'reboot' stuck the server (was not able to reboot) and I was forced to enter the panel of the server and issue a hard reboot. I do not like forced reboots, because 13.XX has another bug and cannot enable journaling on the big storage disk (I have tried many times from single shell 13.0 and 13.1 and it just throws an error).

So I reverted to sendfile off and I will examine in again in 13.2 (or if I boot the server with 12.2 live cd and enable the journaling from there).

NOTE: The nginx processes were stuck at 'D' with wait channel: vofflock , if this can help somebody.
NOTE2: The system was so problematic that I tried to issue less /var/log/nginx/error.log and this was also stuck at 'D' . Eventually, everything that required I/O stuck and a forced reboot was the only option. It was a pain in the a$$ to wait for 1+ hour to fsck 400GB of a live filesystem full of data.
I had same or similar issue few years ago. Finally I had to disable sendfile.



I heard that sendfile is not good when you're on ZFS. Any thoughts on this?
This is correct. sendfile(2) uses the buffer cache to eliminate copying of buffers because UFS buffer cache and sockets share the same buffer cache. However ZFS does not use the buffer cache. It uses the ARC. ARC does not share buffers with the buffer cache. Therefore unlike UFS, contents of ZFS buffers are copied from ARC to MBUFs.

The author of sendfile(2), who was employed at nginx at the time he wrote sendfile(2), commented about this in an email on one of the mailing lists a few months ago. This is a limitation of sendfile() and ZFS. His recommendation was to use sendfile() with UFS.