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

release-19.2: fix server hangs on HTTP timeouts #42539

Merged
merged 4 commits into from
Nov 20, 2019

Conversation

knz
Copy link
Contributor

@knz knz commented Nov 18, 2019

Backport:

Please see individual PRs for details.

/cc @cockroachdb/release

@knz knz requested a review from tbg November 18, 2019 15:23
@knz knz requested a review from a team as a code owner November 18, 2019 15:23
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz changed the title release-19.2: TODO release-19.2: fix server hangs on HTTP timeouts Nov 18, 2019
@tbg
Copy link
Member

tbg commented Nov 18, 2019

LGTM but I'll defer to @bdarnell about postponing this for a few days until after 19.2.1.

Copy link
Contributor

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

LGTM. This should go into 19.2.2, but the commit for 19.2.1 has already been picked so I think this is ready to go after the master commit is merged.

@knz knz force-pushed the backport19.2-42536-42537 branch from 78513bc to 3cb4d5c Compare November 18, 2019 16:41
knz added 4 commits November 20, 2019 21:24
TestRoachLint has problematic memory usage which makes
it inadequate to run on every CI, see issue cockroachdb#42594.

This patch moves it to nightly.

Release note: None
The `shadow` and `printfuncs` testvet invocations are
not amenable to parallelization well.

This patch fixes it.

Release note: None
Previously, various parts of CockroachDB were using the `http`
package's Get/Post/Head methods/functions directly. This was defective
for two reasons:

- it did not implement a request timeout, which could cause
  requests to hang forever if the server was inoperative.
- it did not obey context cancellation, which would force
  the CockroachDB server to hang forever while trying to
  quit if some HTTP server was blocking.

The last point in particular may cause excessive operator friction
when restarting a server, by forcing a node to be killed and
potentially disrupting operation.

This patch fixes the issue by introducing a new `httputil.Client`
class which implements a customizable timeout, see its constructor
`NewClientWithTimeout`.  The default instance in
`httputil.DefaultClient` uses a 3 second timeout.

It also introduces context-aware variants of the `http`
methods/functions `Get`, `Post` and `Head`.  Note that these variants
do not _actually_ obey context cancellation when the code is compiled
with Go 1.12 or prior. The new behavior only kicks in with Go 1.13 or
later (it requires the new feature `NewRequestWithContext`). However,
the usability problem should still be somewhat alleviated in Go 1.12
builds thanks to the request timeout implemented by the new
`httputil.Client`.

The following components in CockroachDB are then adapted to use the
new interface:

- avro registration for changefeed encoders: timeout + cancellation
- telemetry updates: timeout + cancellation
- binfetcher: timeout + cancellation
- cloudinfo: timeout + cancellation
- docgen: timeout, no cancellation (interactive tool)
- roachprod install: timeout, no cancellation (interactive tool)
- test server: timeout, no cancellation (tests have timeouts already)

Release note (bug fix): CockroachDB will now less likely hang in an
inconvenient/inoperative state if it attempts to access an external
HTTP server that blocks or is overloaded. A possible symptom of
the bug is a node failing to shut down upon `cockroach quit`. This
bug is present since at least version 2.0.
Prior to this patch, the CLI interactive tests were running with
diagnostic reporting (including update server checks, telemetry etc)
enabled.

This was unintentional—having implemented the tests initially, I
always worked under the assumption that the acceptance test runner was
disabling telemetry upfront. I only discovered the opposite was true
recently, seeing tests fail with mysterious errors when the telemetry
server happens to be mis-behaving.

This patch fixes the situation by opting the interactive tests out of
telemetry by default. The two tests that check it (with a sensible
fallback) now opt back in explicitly.

Release note: None
@knz knz force-pushed the backport19.2-42536-42537 branch from 3cb4d5c to 24d3fa9 Compare November 20, 2019 20:26
@knz knz merged commit db25255 into cockroachdb:release-19.2 Nov 20, 2019
@knz knz deleted the backport19.2-42536-42537 branch November 20, 2019 21:03
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.

4 participants