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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,16 @@
var reader io.Reader = br
var writer io.Writer = bw

defer func() {
// Close the backupPipe to finish writing on destination.
if err := bw.Close(); err != nil {
createAndCopyErr = errors.Join(createAndCopyErr, vterrors.Wrapf(err, "cannot flush destination: %v", name))

Check warning on line 854 in go/vt/mysqlctl/builtinbackupengine.go

View check run for this annotation

Codecov / codecov/patch

go/vt/mysqlctl/builtinbackupengine.go#L854

Added line #L854 was not covered by tests
}

if err := br.Close(); err != nil {
createAndCopyErr = errors.Join(createAndCopyErr, vterrors.Wrap(err, "failed to close the source reader"))

Check warning on line 858 in go/vt/mysqlctl/builtinbackupengine.go

View check run for this annotation

Codecov / codecov/patch

go/vt/mysqlctl/builtinbackupengine.go#L858

Added line #L858 was not covered by tests
}
}()
// Create the gzip compression pipe, if necessary.
if backupStorageCompress {
var compressor io.WriteCloser
Expand Down Expand Up @@ -891,16 +901,7 @@
}

if err := createAndCopy(); err != nil {
return err
}

// Close the backupPipe to finish writing on destination.
if err = bw.Close(); err != nil {
return vterrors.Wrapf(err, "cannot flush destination: %v", name)
}

if err := br.Close(); err != nil {
return vterrors.Wrap(err, "failed to close the source reader")
return errors.Join(finalErr, err)

Check warning on line 904 in go/vt/mysqlctl/builtinbackupengine.go

View check run for this annotation

Codecov / codecov/patch

go/vt/mysqlctl/builtinbackupengine.go#L904

Added line #L904 was not covered by tests
}

// Save the hash.
Expand Down
2 changes: 1 addition & 1 deletion misc/git/hooks/golangci-lint
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
GOLANGCI_LINT=$(command -v golangci-lint >/dev/null 2>&1)
if [ $? -eq 1 ]; then
echo "Downloading golangci-lint..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
fi

gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '^go/.*\.go$')
Expand Down
Loading