Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Fixes cockroachdb#107930. Epic: CRDB-28893 Co-authored-by: Raphael 'kena' Poss <[email protected]>
- Loading branch information