Close TCP, TLS connections gracefully to avoid data loss #123
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.
Proposed commit message
Checklist
Discussion
This bug was discovered due to flaky tests that use
stream
(issues listed below).For a more detailed discussion of this topic please read the blog post
The ultimate SO_LINGER page, or: why is my tcp not reliable.
I tested this manually. Failures of the old version can be demonstrated as follows. Here I use data from
integrations
that is know to trigger the issue.TLS
In one terminal run this server loop:
In another, repeatedly run this client:
It should fail within a few runs. It fails more readily if the client is run soon after the server starts. If necessary, lowering the rate limit enforced by
pv
may help trigger a failure.TCP
This uses GNU Netcat (BSD Netcat may differ). Having the server write some data seems to be necessary for the error to happen.
The server:
The client:
Related issues