Skip to content

notifier: take the write lock when updating LastEval in sendEvaluatorRequests - #867

Open
ZayanKhan-12 wants to merge 1 commit into
linkedin:masterfrom
ZayanKhan-12:fix/notifier-lasteval-write-lock
Open

notifier: take the write lock when updating LastEval in sendEvaluatorRequests#867
ZayanKhan-12 wants to merge 1 commit into
linkedin:masterfrom
ZayanKhan-12:fix/notifier-lasteval-write-lock

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

Problem

sendEvaluatorRequests holds only the cluster's read lock (consumerGroup.Lock.RLock()) while writing groupInfo.LastEval. A read lock permits concurrent access, so this write can race:

  • Two instances of sendEvaluatorRequests can briefly overlap after a ZooKeeper session bounce — manageEvalLoop spawns a new loop as soon as it reacquires the ZK lock, while the previous loop can still be mid-iteration before it observes doEvaluations == false. Both then read and write LastEval under read locks concurrently.

Fix

Take the write lock for the group iteration. The lock only covers the in-memory loop — the evaluator request send already happens in a spawned goroutine — so no channel sends or network calls happen under the lock, and contention is unchanged in practice.

Testing

go test ./core/internal/notifier/ and go test -race ./... pass (the pre-existing coordinator_race_test.go behavior under -race build tags is unchanged).

🤖 Generated with Claude Code

…Requests

sendEvaluatorRequests held only the cluster's read lock while writing
groupInfo.LastEval. A read lock does not exclude other readers of the
same group state, and two instances of sendEvaluatorRequests can overlap
briefly after a ZooKeeper session bounce (manageEvalLoop spawns a new
loop once it reacquires the lock, while the previous loop can still be
mid-iteration before observing doEvaluations == false), so the write can
race. Writes to shared state need the write lock.

The lock is only held for the in-memory iteration - the evaluator
request send happens in a spawned goroutine - so this does not hold the
lock across any channel sends or network calls.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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