Skip to content

Always close body for HTTP requests in tests#10835

Merged
vmg merged 1 commit intovitessio:mainfrom
planetscale:dbussink/always-close-body
Jul 27, 2022
Merged

Always close body for HTTP requests in tests#10835
vmg merged 1 commit intovitessio:mainfrom
planetscale:dbussink/always-close-body

Conversation

@dbussink
Copy link
Member

Not closing the body leads to leaking goroutines for the reader / writer of the body.

Found when validating that tests don't leak goroutines (to ensure other things get closed properly, but these cases where also found).

Related Issue(s)

See also #10756 for another set of leak fixes.

Checklist

  • "Backport me!" label has been added if this change should be backported
  • Tests were added or are not required
  • Documentation was added or is not required

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Jul 26, 2022

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.
  • If a new flag is being introduced, review whether it is really needed. The flag names should be clear and intuitive (as far as possible), and the flag's help should be descriptive. Additionally, flag names should use dashes (-) as word separators rather than underscores (_).
  • If a workflow is added or modified, each items in Jobs should be named in order to mark it as required. If the workflow should be required, the GitHub Admin should be notified.

Bug fixes

  • There should be at least one unit or end-to-end test.
  • The Pull Request description should either include a link to an issue that describes the bug OR an actual description of the bug and how to reproduce, along with a description of the fix.

Non-trivial changes

  • There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • Should be documented, either by modifying the existing documentation or creating new documentation.
  • New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • vtctl command output order should be stable and awk-able.

@dbussink dbussink changed the title Always close body for HTTP requests Always close body for HTTP requests in tests Jul 26, 2022
Not closing the body leads to leaking goroutines for the reader / writer
of the body.

Found when validating that tests don't leak goroutines (to ensure other
things get closed properly, but these cases where also found).

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
@dbussink dbussink force-pushed the dbussink/always-close-body branch from 98b7e5a to 24835a6 Compare July 26, 2022 13:29
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

LGTM

@vmg vmg merged commit 2e13a38 into vitessio:main Jul 27, 2022
@vmg vmg deleted the dbussink/always-close-body branch July 27, 2022 08:04
rsajwani pushed a commit to planetscale/vitess that referenced this pull request Aug 1, 2022
Not closing the body leads to leaking goroutines for the reader / writer
of the body.

Found when validating that tests don't leak goroutines (to ensure other
things get closed properly, but these cases where also found).

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
dbussink added a commit to planetscale/vitess that referenced this pull request Nov 30, 2022
Not closing the body leads to leaking goroutines for the reader / writer
of the body.

Found when validating that tests don't leak goroutines (to ensure other
things get closed properly, but these cases where also found).

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
frouioui pushed a commit that referenced this pull request Nov 30, 2022
* Fix closing the body for HTTP requests (#11842)

One of the easy things to miss that can cause resource leaks is not
closing a response body for an HTTP request.

There's a linter available to make it easier to catch this, so this
enables that linter and fixes all the cases reported.

This is almost all test cases, except for one production code path case
in the throttler.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Always close body for HTTP requests (#10835)

Not closing the body leads to leaking goroutines for the reader / writer
of the body.

Found when validating that tests don't leak goroutines (to ensure other
things get closed properly, but these cases where also found).

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Fix remaining body close issues

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
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.

3 participants