-
Notifications
You must be signed in to change notification settings - Fork 724
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
Log chain shutdown duration #1545
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,15 +368,21 @@ func (cr *ChainRouter) Shutdown(ctx context.Context) { | |
chain.Stop(ctx) | ||
} | ||
|
||
ticker := time.NewTicker(cr.closeTimeout) | ||
defer ticker.Stop() | ||
ctx, cancel := context.WithTimeout(ctx, cr.closeTimeout) | ||
defer cancel() | ||
|
||
for _, chain := range prevChains { | ||
select { | ||
case <-chain.Stopped(): | ||
case <-ticker.C: | ||
cr.log.Warn("timed out while shutting down the chains") | ||
return | ||
shutdownDuration, err := chain.AwaitStopped(ctx) | ||
|
||
chainLog := chain.Context().Log | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is the same as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the same as |
||
if err != nil { | ||
chainLog.Warn("timed out while shutting down", | ||
zap.Error(err), | ||
) | ||
} else { | ||
chainLog.Info("chain shutdown", | ||
zap.Duration("shutdownTime", shutdownDuration), | ||
) | ||
} | ||
} | ||
} | ||
|
@@ -646,12 +652,19 @@ func (cr *ChainRouter) removeChain(ctx context.Context, chainID ids.ID) { | |
|
||
chain.Stop(ctx) | ||
|
||
ticker := time.NewTicker(cr.closeTimeout) | ||
defer ticker.Stop() | ||
select { | ||
case <-chain.Stopped(): | ||
case <-ticker.C: | ||
chain.Context().Log.Warn("timed out while shutting down") | ||
ctx, cancel := context.WithTimeout(ctx, cr.closeTimeout) | ||
shutdownDuration, err := chain.AwaitStopped(ctx) | ||
cancel() | ||
|
||
chainLog := chain.Context().Log | ||
if err != nil { | ||
chainLog.Warn("timed out while shutting down", | ||
zap.Error(err), | ||
) | ||
} else { | ||
chainLog.Info("chain shutdown", | ||
zap.Duration("shutdownTime", shutdownDuration), | ||
StephenButtolph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
|
||
if cr.onFatal != nil && cr.criticalChains.Contains(chainID) { | ||
|
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.
Note: the
return
isn't needed here anymore becauseAwaitStopped
will correctly report if the shutdown timed out.