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

cloud: close Reader before resetting in ResumingReader #75149

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

adityamaru
Copy link
Contributor

This change Close()s the Reader before resetting it when we
encounter a resumable error in the ResumingReader. This is particularly
important for the http external storage provide, since forgetting to
call Close() results in goroutine leaks from go1.17.6 onwards.

See: golang/go#50652

Fixes: #75143

Release note: None

@adityamaru adityamaru requested review from knz, a team and dt and removed request for a team January 19, 2022 15:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@@ -231,6 +231,7 @@ func (r *ResumingReader) Read(p []byte) (int, error) {
}
log.Errorf(r.Ctx, "Retry IO: error %s", lastErr)
lastErr = nil
r.Reader.Close()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm actually i think we need a nil check here incase the call to r.Open() failed.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM modulo the additional fix you've identified already

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru and @dt)


pkg/cloud/cloud_io.go, line 234 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

hmm actually i think we need a nil check here incase the call to r.Open() failed.

yep

This change `Close()`s the Reader before resetting it when we
encounter a resumable error in the ResumingReader. This is particularly
important for the http external storage provide, since forgetting to
call Close() results in goroutine leaks from go1.17.6 onwards.

See: golang/go#50652

Release note: None
@adityamaru
Copy link
Contributor Author

Bazel failure is an unrelated timeout of kvserver package.

bors r=knz

@craig
Copy link
Contributor

craig bot commented Jan 19, 2022

Build succeeded:

@craig craig bot merged commit 9547bc9 into cockroachdb:master Jan 19, 2022
@adityamaru adityamaru deleted the close-http-on-retry branch January 19, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg/cloud: ResumingReader incorrectly forgets to call .Close() on its ReadCloser
3 participants