-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
xds/client: hold authority mutex before making a new authority #5331
Conversation
xds/internal/xdsclient/loadreport.go
Outdated
@@ -28,7 +28,9 @@ import ( | |||
// It returns a Store for the user to report loads, a function to cancel the | |||
// load reporting stream. | |||
func (c *clientImpl) ReportLoad(server *bootstrap.ServerConfig) (*load.Store, func()) { | |||
c.authorityMu.Lock() | |||
a, err := c.newAuthority(server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we name the function newAuthorityLocked
to better indicate you should have the lock when calling it? I see it's in the doc comments but those obviously weren't sufficient in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Rename this and several other methods.
c33c665
to
a428cd3
Compare
xds/internal/xdsclient/loadreport.go
Outdated
@@ -38,6 +40,6 @@ func (c *clientImpl) ReportLoad(server *bootstrap.ServerConfig) (*load.Store, fu | |||
store, cancelF := a.reportLoad() | |||
return store, func() { | |||
cancelF() | |||
c.unrefAuthority(a) | |||
c.unrefAuthorityLocked(a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this cleanup function always invoked with the lock held?
xds/internal/xdsclient/watchers.go
Outdated
@@ -28,7 +28,7 @@ import ( | |||
// after the watcher is canceled. The caller needs to handle this case. | |||
func (c *clientImpl) WatchListener(serviceName string, cb func(xdsresource.ListenerUpdate, error)) (cancel func()) { | |||
n := xdsresource.ParseName(serviceName) | |||
a, unref, err := c.findAuthority(n) | |||
a, unref, err := c.findAuthorityLocked(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lock isn't held? And below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, the other two actually says must not hold mu
.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geez, who wrote this code? 😉
8a36f55
to
900c8ef
Compare
fixes #5328
Caller must hold the mutex before calling
newAuthority
.RELEASE NOTES: