Skip to content

relaymonitor: guard DuplicateBidCache with a mutex - #881

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/relaymonitor-duplicate-bid-cache-mutex
Open

relaymonitor: guard DuplicateBidCache with a mutex#881
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/relaymonitor-duplicate-bid-cache-mutex

Conversation

@damilolaedwards

Copy link
Copy Markdown

Summary

Set and Has read and wrote the underlying map with no synchronization. Every configured relay gets its own goroutine calling into the shared cache (one per slot time offset, plus the consistency coordinator), so concurrent first inserts into the map were a real race, not just a theoretical one, and could crash the whole process.

Added a mutex around the map lookup and creation, and moved cache creation into a single getOrCreateCache helper so there is one place that touches the map under lock.

Test plan

  • go build ./...
  • go test ./pkg/relaymonitor/... -race
  • New tests simulate concurrent Set/Has calls across multiple relays and concurrent first inserts for the same relay, run under -race

Set and Has read and wrote the underlying map with no synchronization.
Every configured relay gets its own goroutine calling into the shared
cache (one per slot-time offset, plus the consistency coordinator), so
concurrent first-inserts into the map were a real race, not just a
theoretical one, and could crash the whole process.

Added a mutex around the map lookup and creation, and moved cache
creation into a single getOrCreateCache helper so there is one place
that touches the map under lock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant