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 backup goroutine leak #15410

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

deepthi
Copy link
Member

@deepthi deepthi commented Mar 6, 2024

Description

Close the reader and writer in a defer func. This ensures that the progress goroutine receives a message on the done channel and returns.

Note that the golangci-lint hook broke after the go1.22 upgrade, so I've updated it to the latest version.

Related Issue(s)

Fixes #15409

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

@deepthi deepthi requested a review from mattlord as a code owner March 6, 2024 02:24
Copy link
Contributor

vitess-bot bot commented Mar 6, 2024

Review Checklist

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

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Mar 6, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Mar 6, 2024
@deepthi
Copy link
Member Author

deepthi commented Mar 6, 2024

For reference, here's the stack trace from the old version of golangci-lint

ERRO [runner] Panic: SA1027: package "mysqlctl" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 9849 [running]:
runtime/debug.Stack()
	/Users/deepthi/.gvm/gos/go1.22.1/src/runtime/debug/stack.go:24 +0x64
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:102 +0x108
panic({0x10194be20?, 0x102255290?})
	/Users/deepthi/.gvm/gos/go1.22.1/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x101aafc90, 0x10226ca80})
	/Users/deepthi/.gvm/gos/go1.22.1/src/go/types/sizes.go:228 +0x314
honnef.co/go/tools/staticcheck.checkAtomicAlignmentImpl(0x1400dc681e0)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:773 +0x64
honnef.co/go/tools/staticcheck.checkCalls.func1(0x102261330?, {0x101ac4750, 0x14003882b00}, 0x14002c0b540)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:3279 +0x298
honnef.co/go/tools/staticcheck.eachCall(0x1400c9257c0, 0x1400b1cdcd8)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:2648 +0x190
honnef.co/go/tools/staticcheck.checkCalls(0x14001839d18?, 0x100fbfb24?)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:3320 +0x90
honnef.co/go/tools/staticcheck.init.makeCallCheckerAnalyzer.callChecker.func64(0x101938a80?)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/honnef.co/go/[email protected]/staticcheck/lint.go:3247 +0x20
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0x140017ba4a0)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:188 +0x8b8
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:106 +0x20
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x140016e6690, {0x1015947aa, 0x6}, 0x14001839f30)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x100fc2150?)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:105 +0x78
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x140017ba4a0)
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb0
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 9
	/Users/deepthi/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x170
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: SA1027: package "mysqlctl" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: goanalysis_metalinter: SA1027: package "mysqlctl" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference

@deepthi
Copy link
Member Author

deepthi commented Mar 6, 2024

CI is running with

run: go install github.com/golangci/golangci-lint/cmd/[email protected]

@deepthi deepthi requested review from frouioui and shlomi-noach March 6, 2024 02:30
@frouioui frouioui added Type: Bug Component: General Changes throughout the code base and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Mar 6, 2024
@frouioui frouioui added Component: Backup and Restore and removed Component: General Changes throughout the code base labels Mar 6, 2024
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 65.64%. Comparing base (696fe0e) to head (f28ae15).
Report is 84 commits behind head on main.

Files Patch % Lines
go/vt/mysqlctl/builtinbackupengine.go 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15410      +/-   ##
==========================================
- Coverage   67.41%   65.64%   -1.78%     
==========================================
  Files        1560     1562       +2     
  Lines      192752   193941    +1189     
==========================================
- Hits       129952   127307    -2645     
- Misses      62800    66634    +3834     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mdlayher mdlayher left a comment

Choose a reason for hiding this comment

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

LGTM!

@deepthi
Copy link
Member Author

deepthi commented Mar 6, 2024

I don't think it's really necessary to backport to older releases. We can do it if someone asks.

@deepthi deepthi merged commit 38ebdb3 into vitessio:main Mar 6, 2024
110 of 116 checks passed
@deepthi deepthi deleted the ds-fix-backup-goroutine-leak branch March 6, 2024 19:44
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.

Bug Report: builtin backup leaks goroutine when it fails
4 participants