-
Notifications
You must be signed in to change notification settings - Fork 3.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
gossip: remove race on client peer id #122440
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Nice catch! Interestingly enough we introduced by an attempt to address incorrect unlocking: #108064.
I don't think this lint would have helped here though although I'm not positivev. In gossip we are acquiring the |
Looking at this a little more, there is at least one more usage of There are also uses of Can you also add a comment on I think there is also a bug in |
a09ec3f
to
cfbd9f6
Compare
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.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @kvoli)
pkg/gossip/client.go
line 36 at r1 (raw file):
createdAt time.Time // peerID is the node ID of the peer we're connected to. This is set when we // receive a response from the peer. The gossip mu should be held when
I found it a bit surprising that we're using gossip mu here, but then I came across this comment:
cockroach/pkg/gossip/gossip.go
Lines 228 to 229 in 25232a6
// Note that access to each client's internal state is serialized by the | |
// embedded server's mutex. This is surprising! |
Is this the "surprise" it's talking about?
pkg/gossip/client.go
line 335 at r1 (raw file):
initCh <- struct{}{} } if peerID == 0 {
We don't seem to be doing anything meaningful with this. Should we just get rid of peerID
entirely?
The gossip client `peerID` was accessed outside of the gossip mutex, leading to concurrent access. Serialize access by acquiring the gossip mutex. Fixes: cockroachdb#122435 Release note: None
cfbd9f6
to
d357a32
Compare
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.
TYFTR
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @arulajmani)
pkg/gossip/client.go
line 36 at r1 (raw file):
Previously, arulajmani (Arul Ajmani) wrote…
I found it a bit surprising that we're using gossip mu here, but then I came across this comment:
cockroach/pkg/gossip/gossip.go
Lines 228 to 229 in 25232a6
// Note that access to each client's internal state is serialized by the // embedded server's mutex. This is surprising! Is this the "surprise" it's talking about?
Indeed.
pkg/gossip/client.go
line 335 at r1 (raw file):
Previously, arulajmani (Arul Ajmani) wrote…
We don't seem to be doing anything meaningful with this. Should we just get rid of
peerID
entirely?
Nice, I didn't notice -- removed.
bors r=arulajmani |
The gossip client
peerID
was accessed outside of the gossip mutex,leading to concurrent access. Serialize access by acquiring the gossip
mutex.
Fixes: #122435
Release note: None