You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
108401: server: avoid a race in the server controller r=lidorcarmel a=knz
Co-authored with `@lidorcarmel`
Prior to this patch, the Go race detector was complaining about racy concurrent accesses to `serverStateUsingChannels.server`, via `(*serverStateUsingChannels) getServer()` and `(*channelOrchestrator) startControlledServer()`.
These racy accesses happened to be safe because the writes and reads to that field were correctly ordered around updates to an atomic bool (the `started` field). However, the race detector is not sufficiently sophisticated to detect this ordering and satisfy itself that the state transition can only happen once.
In order to silence the race detector (with no change in correctness), this patch replaces the atomic bool by a mutex, whose access semantics are properly understood by the race detector.
This change incidentally makes the code slightly easier to read and understand.
Supersedes cockroachdb#108371.
Fixescockroachdb#107930.
Epic: CRDB-28893
Co-authored-by: Raphael 'kena' Poss <[email protected]>
0 commit comments