Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close a TCP connection when indicated by Connection: Close header. #447

Merged

Conversation

mikkokar
Copy link
Contributor

Introduction

Close the TCP connection when indicated by Connection: close header in the received response.

Background

So far, Styx has ignored the received Connection: close header, and relied on sender to close the TCP connection, and on Netty to deliver a channelInactive event. This behaviour introduces a race condition that subtly increases failed requests manifesting in Styx 502 responses.

This behaviour unnecessarily delays the connection removal, and is a problematic specifically with pooled connections. A pooled connection may be reused for another request wile the operating system and/or TCP protocol is processing connection closure (transmitting FIN). When a request is sent on such a connection, it will be rejected by the remote peer, resulting in a TCP reset.

Solution

Check if the Connection: close header is present in a response. If so, close the connection straight away. This taints the connection so that it won't be used for any future requests, eliminating the race condition.

@mikkokar mikkokar requested review from kvosper and dvlato July 18, 2019 11:45
@mikkokar mikkokar merged commit 02500b1 into ExpediaGroup:master Jul 18, 2019
@mikkokar mikkokar deleted the fix-response-connection-close branch July 18, 2019 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants