container/state.go: fix race in StateString()#28912
Conversation
|
CI hanging |
|
Looks valid. That stuff is really bad. |
|
BTW Gordon not recognizing |
|
Just wondering - why was it racey w/o the use of the lock? Is it because the s.* properties could change values 1/2 thru the processing of that func? |
|
@duglin Yes, and could potentially even cause a panic. |
|
@LK4D4 #28483 is the start of removing this lock altogether. |
|
could we not remove the lock and instead just copy the state into a local variable and then examine that? That should make it thread safe, no? |
|
@duglin It's racey to look at the state without holding the lock, and just reading the state string is super fast. It's not about lock contention here, it's an issue of deadlocks.... in this case due to a goroutine trying to double-lock the container. This lock is doing way way too much and it's causing lots of problems. |
Signed-off-by: Alexander Morozov <[email protected]>
|
@cpuguy83 I've added lock in specific place with race. I understand that it's bad, but lock is still there :/ |
|
@LK4D4 is there a way to add a test for that race? |
|
@mlaventure there is no state tests at all :/ I can write one specifically for that race, but seems like we didn't run with |
|
I think the main place where this is a problem is in |
|
@cpuguy83 can we merge this in the meantime? |
|
I really don't like locking the container mutex here. |
|
what's the conclusion? |
|
I'm going to close this. |
Overall State struct is extremely weird because it exposes Lock() and Unlock() which actively used by outside code. But I'm not sure how to fix that.
ping @mlaventure