-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 race condition in TestIntegrations - Disconnection #11737
Conversation
@@ -1271,6 +1271,9 @@ func sessionsStreamingUploadDir(ctx *ServerContext) string { | |||
} | |||
|
|||
func (s *session) broadcastResult(r ExecResult) { | |||
s.mu.Lock() |
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.
I think this can deadlock.
(*SessionRegistry).broadcastResult()
acquires the lock and then calls (*session).boradcastResult()
, which will attempt to acquire a lock that it already holds.
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.
@zmb3 I don't think this is the case. The fist lock as you pointed out is in SessionRegistry
and the one that I've added is in session
Lines 67 to 68 in 7c7bb75
type SessionRegistry struct { | |
mu sync.Mutex |
Lines 530 to 531 in 7c7bb75
type session struct { | |
mu sync.RWMutex |
Alternative solution would be to move the
SessionRegistry
lock inside (*SessionRegistry).findSessionLocked()
as I don't think that is needed during (*session).broadcastResult()
call and leave the extra lock that I've added, but I'm not familiar with this part of code.
Fix race condition reported by TestIntegrations - Disconnection
Fix race condition reported by TestIntegrations - Disconnection Backport of #11737
Add mutex to
session.broadcastResult()
to fix race condition reported by Go thread sanitizer.