-
Notifications
You must be signed in to change notification settings - Fork 141
adding termination error logging #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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"})) |
There was a problem hiding this comment.
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.
No description provided.