telemetry: do not recreate a stats worker for a released guard (#4860)

* telemetry: do not recreate a stats worker for a released guard

A ParticipantActive overtaken by the participant's close arrives with a
guard ParticipantLeft already released and replaced the closed worker
with one nothing could release.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* telemetry: handle a released guard independently of map presence

A released guard reaching getOrCreateWorker after the closed worker was
reaped still created a zero-reference worker. Return nil as found
instead, and make SetConnected nil-safe for ParticipantActive.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Raja Subramanian
2026-09-11 21:23:13 +05:30
committed by GitHub
co-authored by Claude Fable 5.1
parent c6f3ceba10
commit 7c82d3e103
3 changed files with 45 additions and 0 deletions
+8
View File
@@ -302,6 +302,14 @@ func (t *telemetryService) getOrCreateWorker(
return worker, true
}
// only ParticipantLeft releases a guard, so a released guard is a call landing after
// the participant left, e.g. ParticipantActive overtaken by the close. Do not create
// a worker nothing can ever release. The closed worker, if not yet reaped, is returned
// as found, otherwise nil is
if guard != nil && guard.released {
return worker, true
}
existingIsConnected := false
if ok {
existingIsConnected = worker.IsConnected()