Immediately close bad connections to prevent file exhaustion #6112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
osrm-routed
does not immediately clean up a keep-alive connection when the client closes it. Instead it waits for five seconds of inactivity before removing.Given a setup with low file limits and clients opening and closing a lot of keep-alive connections, it's possible for
osrm-routed
to run out of file descriptors whilst it waits for the clean-up to trigger.Furthermore, this causes the connection acceptor loop to exit.
Even after the old connections are cleaned up, new ones will not be created. Any new requests will block until the
server is restarted.
You can replicate this by limiting the number of open files (e.g. on Linux
ulimit -n 100
) and running a script that makes a curl request to a server endpoint in a loop.This commit improves the situation by:
Immediately closing connections on error. This includes EOF errors
indicating that the client has closed the connection. This releases
resources early (including the open file) and doesn't wait for the
timer.
Log when the acceptor loop exits. Whilst this means the behaviour
can still occur for reasons other than too many open files,
we will at least have visibility of the cause and can investigate further.
Tasklist
Requirements / Relations
Fixes #6040