Hi, I am leaking file descriptors in my phoenix 1.4.5 app.
Situation is that I have a phoenix app with a bunch of stuff in /priv/static that has had “mix phx.digest” run against it and also an “uploads” dir symlinked in which has not
I have a bot which appears to be searching me called “AhrefsBot/6.1” and this appears to be requesting image files, then terminating the TCP connection before downloading the complete file (only for images). Nginx is in front of my phoenix app and is logging the disconnect (and referrer).
These early disconnects are causing a file handle leak and eventually the elixir apps stops being able to serve assets due to lack of file handles…
lsof shows a ton of open filehandles, but ONLY for these specific files which are:
- served by the plug.static module
- are in the path symlinked into the ./priv/static/ dir
- were not there when mix phx.digest was run (although this may not be significant)
Restarting nginx doesn’t lower the file handle usage, so it’s not that nginx is keeping connections open. Restarting the elixir process sets file handles to zero again
I’m not clear that the use of the symlink is causing the issue, but it sure looks like the dropping the connection without downloading the whole file is. ie I’m not seeing any other client cause the file handle to leak when viewing these assets
Eyeballing the code, I think this implies some leak in Plug.send_file ? Any ideas?