Skip to content

Audit/Tests for Go Leaks#10756

Closed
mattlord wants to merge 8 commits intovitessio:mainfrom
planetscale:tkr_cleanup
Closed

Audit/Tests for Go Leaks#10756
mattlord wants to merge 8 commits intovitessio:mainfrom
planetscale:tkr_cleanup

Conversation

@mattlord
Copy link
Member

@mattlord mattlord commented Jul 19, 2022

Description

I did a quick audit of places where we were using a confined Ticker — created as a local variable in a function — but not ensuring it gets stopped with a defer statement. This will help to prevent resource leaks. This was prompted by the fact I realized I forgot to do this in a PR yesterday: #10720

I'm also investigating usage of this: https://github.com/uber-go/goleak
Unfortunately this does not seem useful to use in e2e tests.

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

Otherwise we leak some resources.

Signed-off-by: Matt Lord <mattalord@gmail.com>
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Jul 19, 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.

mattlord added 2 commits July 19, 2022 14:02
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord changed the title Quick audit of NewTimer usage w/o a defer to ensure it's stopped Quick audit of NewTicker usage w/o a defer to ensure it's stopped Jul 20, 2022
mattlord added 2 commits July 20, 2022 11:03
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord requested a review from rohit-nayak-ps July 20, 2022 15:03
mattlord added 2 commits July 20, 2022 12:45
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord changed the title Quick audit of NewTicker usage w/o a defer to ensure it's stopped Audit/Tests for Go Leaks Jul 20, 2022
@mattlord mattlord marked this pull request as draft July 20, 2022 18:41
Signed-off-by: Matt Lord <mattalord@gmail.com>
Copy link
Collaborator

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

This looks good in principle.
What did you mean by the goleak library not being useful in e2e tests?

}
if depth == len(cont.Path) {
leaf = &cont
leaf = &cont // nolint:exportloopref
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed differently by @dbussink in #10765

@mattlord
Copy link
Member Author

This looks good in principle.
What did you mean by the goleak library not being useful in e2e tests?

Seems that it only tests the main command go test executes whereas the e2e tests start up a bunch of processes.

@github-actions
Copy link
Contributor

This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:

  • Push additional commits to the associated branch.
  • Remove the stale label.
  • Add a comment indicating why it is not stale.

If no action is taken within 7 days, this PR will be closed.

@github-actions github-actions bot added the Stale Marks PRs as stale after a period of inactivity, which are then closed after a grace period. label Aug 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

This PR was closed because it has been stale for 7 days with no activity.

@github-actions github-actions bot closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: General Changes throughout the code base Do Not Merge Stale Marks PRs as stale after a period of inactivity, which are then closed after a grace period. Type: Internal Cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants