Skip to content

VStream API: Fix vtgate memory leaks when context gets cancelled#10571

Merged
rohit-nayak-ps merged 1 commit intovitessio:mainfrom
planetscale:rn-vstream-leak
Jun 24, 2022
Merged

VStream API: Fix vtgate memory leaks when context gets cancelled#10571
rohit-nayak-ps merged 1 commit intovitessio:mainfrom
planetscale:rn-vstream-leak

Conversation

@rohit-nayak-ps
Copy link
Copy Markdown
Member

@rohit-nayak-ps rohit-nayak-ps commented Jun 22, 2022

Description

This PR fixes a couple of memory leaks in the VStream API which was causing vtgates to OOM.

  • Check for cancelled context when events received from the source were being sent into a event channel for eventual streaming to the vstream api client.
  • When a context is cancelled, in the vstream API we need to return an error in the health streamer callback. Otherwise it keeps streaming and leaking (goroutines and ) grpc request buffers.

Signed-off-by: Rohit Nayak rohit@planetscale.com

Related Issue(s)

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

@github-actions
Copy link
Copy Markdown
Contributor

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.
  • 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.

@rohit-nayak-ps rohit-nayak-ps marked this pull request as draft June 22, 2022 21:03
@rohit-nayak-ps rohit-nayak-ps force-pushed the rn-vstream-leak branch 2 times, most recently from e8624be to 0da0cc3 Compare June 23, 2022 11:24
@rohit-nayak-ps rohit-nayak-ps changed the title VStream API: Exit from health streamer in case of error. VStream API: Experiments for determining vtgate memory leaks as a result of periodic vstream API calls Jun 23, 2022
@rohit-nayak-ps rohit-nayak-ps force-pushed the rn-vstream-leak branch 3 times, most recently from dcab906 to 930b8db Compare June 24, 2022 08:26
…hannel might block the vstream thread if target channel goes away: context was not being checked then. Fix health stream goroutine leak.

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
@rohit-nayak-ps rohit-nayak-ps changed the title VStream API: Experiments for determining vtgate memory leaks as a result of periodic vstream API calls VStream API: Fix vtgate memory leaks when context gets cancelled Jun 24, 2022
@rohit-nayak-ps rohit-nayak-ps requested a review from mattlord June 24, 2022 08:37
@rohit-nayak-ps rohit-nayak-ps marked this pull request as ready for review June 24, 2022 09:22
@rohit-nayak-ps rohit-nayak-ps deleted the rn-vstream-leak branch June 24, 2022 15:19
rohit-nayak-ps added a commit to planetscale/vitess that referenced this pull request Jul 21, 2022
…hannel might block the vstream thread if target channel goes away: context was not being checked then. Fix health stream goroutine leak. (vitessio#10571)

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
rohit-nayak-ps added a commit that referenced this pull request Jul 21, 2022
…hannel might block the vstream thread if target channel goes away: context was not being checked then. Fix health stream goroutine leak. (#10571) (#10780)

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
@deepthi
Copy link
Copy Markdown
Collaborator

deepthi commented Jul 30, 2022

We've already included this in v13.0.2. Based on the report in slack we should back port it to release-12.0 as well.

mattlord pushed a commit to planetscale/vitess that referenced this pull request Aug 3, 2022
…hannel might block the vstream thread if target channel goes away: context was not being checked then. Fix health stream goroutine leak. (vitessio#10571)

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
DeathBorn pushed a commit to vinted/vitess that referenced this pull request Jan 26, 2023
…hannel might block the vstream thread if target channel goes away: context was not being checked then. Fix health stream goroutine leak. (vitessio#10571)

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Matt Lord <mattalord@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