Skip to content

Conversation

@alexlivekit
Copy link
Contributor

No description provided.

@alexlivekit alexlivekit requested a review from a team as a code owner January 21, 2026 19:18
Comment on lines +1133 to 1141
go func() {
time.Sleep(5 * time.Minute)
if !c.terminated.Load() {
c.mon.CallTerminationFailure()
c.log().Errorw("call failed to terminate after 5 minutes", nil) // To be able to get call IDs
}
}()

ctx = context.WithoutCancel(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
go func() {
time.Sleep(5 * time.Minute)
if !c.terminated.Load() {
c.mon.CallTerminationFailure()
c.log().Errorw("call failed to terminate after 5 minutes", nil) // To be able to get call IDs
}
}()
ctx = context.WithoutCancel(ctx)
ctx = context.WithoutCancel(ctx) // do not timeout
ctx, cancel := context.WithCancel(ctx)
defer cancel()
go func() {
select {
case <-ctx.Done():
return
case <-time.After(5 * time.Minute):
if !c.terminated.Load() {
c.mon.CallTerminationFailure()
c.log().Errorw("call failed to terminate after 5 minutes", nil) // To be able to get call IDs
}
}
}()

We shouldn't block a goroutine unconditionally, it should also select on the context of the parent call.

Also, this should be after the CAS on c.done, so that we don't run an extra goroutine if Close is called twice.

}

c.cancel()
c.terminated.Store(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe defer it?


func (c *outboundCall) stopSIP(ctx context.Context, reason string) {
go func() {
time.Sleep(5 * time.Minute)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we shouldn't block unconditionally.

}

func (c *CallMonitor) CallTerminationFailure() {
c.m.callsTerminationFailures.With(c.labels(prometheus.Labels{})).Inc()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c.m.callsTerminationFailures.With(c.labels(prometheus.Labels{})).Inc()
c.m.callsTerminationFailures.With(c.labels(nil)).Inc()

Name: "calls_termination_failures",
Help: "Number of calls that failed to terminate after 5 minutes",
ConstLabels: prometheus.Labels{"node_id": conf.NodeID},
}, []string{"dir"}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling c.labels will add to as well, which is not defined here. This will likely panic.

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.

4 participants