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

Fix Watcher HTTP connection config for longevity #72736

Conversation

DaveCTurner
Copy link
Contributor

Watcher uses a connection pool for outgoing HTTP traffic, which means
that some HTTP connections may live for a long time, possibly in an idle
state. Such connections may be silently torn down by a remote device, so
that when we re-use them we encounter a Connection reset or similar
error.

This commit introduces a setting allowing users to set a finite expiry
time on these connections, and also enables TCP keepalives on them by
default so that a remote teardown will be actively detected sooner.

Closes #52997

Watcher uses a connection pool for outgoing HTTP traffic, which means
that some HTTP connections may live for a long time, possibly in an idle
state. Such connections may be silently torn down by a remote device, so
that when we re-use them we encounter a `Connection reset` or similar
error.

This commit introduces a setting allowing users to set a finite expiry
time on these connections, and also enables TCP keepalives on them by
default so that a remote teardown will be actively detected sooner.

Closes elastic#52997
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@@ -770,6 +770,50 @@ public void testCreateUri() throws Exception {
assertCreateUri("https://example.org", "");
}

public void testConnectionReuse() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the least flaky way I could think of to test this but it's not exactly watertight, we cannot 100% guarantee that the connection will be re-used in the first case, nor can we guarantee that the client port won't be re-used in the second case.

I also couldn't work out a way to test that TCP keepalives are enabled at all.

@DaveCTurner
Copy link
Contributor Author

@elasticmachine please run elasticsearch-ci/2

@DaveCTurner
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks David, these changes look good and is much better then current workaround of sending a connection closed header to force non-persistent connections.

@DaveCTurner DaveCTurner merged commit 3e0959f into elastic:master May 6, 2021
@DaveCTurner DaveCTurner deleted the 2021-05-05-watcher-long-lived-http-connections branch May 6, 2021 07:28
DaveCTurner added a commit that referenced this pull request May 6, 2021
Watcher uses a connection pool for outgoing HTTP traffic, which means
that some HTTP connections may live for a long time, possibly in an idle
state. Such connections may be silently torn down by a remote device, so
that when we re-use them we encounter a `Connection reset` or similar
error.

This commit introduces a setting allowing users to set a finite expiry
time on these connections, and also enables TCP keepalives on them by
default so that a remote teardown will be actively detected sooner.

Closes #52997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watcher webhooks fail with invalidated SSL sessions
3 participants