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

feat(storage): fix mutex use and CloseSend before close #11432

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shubham-diwakar
Copy link
Contributor

@shubham-diwakar shubham-diwakar commented Jan 10, 2025

  1. Make CloseSend() call before releasing resource.
  2. Make change to some mutex calls.
    Removed mutex call around getActiveRange as that will be called from one go routine at a single time.
    Added mutex call around streamReceiver ctx.Done() case similar to streamManager.
  3. Tested all MRD tests with -race.

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Jan 10, 2025
@shubham-diwakar shubham-diwakar marked this pull request as ready for review January 10, 2025 13:54
@shubham-diwakar shubham-diwakar requested review from a team as code owners January 10, 2025 13:54
Comment on lines -1376 to 1378
r.mu.Lock()
defer r.mu.Unlock()
var activeRange []rangeSpec
Copy link
Contributor

@BrennaEpp BrennaEpp Jan 11, 2025

Choose a reason for hiding this comment

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

What's the guarantee here? That if getActiveRange is running, no other goroutine will be running as well that may access the map? I don't think we can guarantee that since Wait() might be running, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can trigger this situation running go test -v -short -run="TestRetryConformance/grpc-8-\[return-broken-stream\]-storage.objects.download-3" -race

Comment on lines +1472 to +1474
if err := mr.stream.CloseSend(); err != nil {
return err
}
Copy link
Contributor

@BrennaEpp BrennaEpp Jan 11, 2025

Choose a reason for hiding this comment

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

Should we also drain the stream after the CloseSend (as we do in drainInboundStream(), receiving from stream until we get a non-nil error) to make sure its resources are released? See grpc/grpc-go@365770f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants