Skip to content
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

go/consensus/tendermint: Don't panic on context cancellation #2982

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/2982.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/consensus/tendermint: Don't panic on context cancellation
6 changes: 3 additions & 3 deletions go/consensus/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (m *failMonitor) markCleanShutdown() {
m.isCleanShutdown = true
}

func newFailMonitor(logger *logging.Logger, fn func()) *failMonitor {
func newFailMonitor(ctx context.Context, logger *logging.Logger, fn func()) *failMonitor {
// Tendermint in it's infinite wisdom, doesn't terminate when
// consensus fails, instead opting to "just" log, and tear down
// the ConsensusState. Since this behavior is stupid, watch for
Expand All @@ -178,7 +178,7 @@ func newFailMonitor(logger *logging.Logger, fn func()) *failMonitor {
m.Lock()
defer m.Unlock()

if !m.isCleanShutdown {
if !m.isCleanShutdown && ctx.Err() == nil {
logger.Error("unexpected termination detected")
panic("tendermint: unexpected termination detected, consensus failure?")
}
Expand Down Expand Up @@ -1150,7 +1150,7 @@ func (t *tendermintService) lazyInit() error {
return fmt.Errorf("tendermint: internal error: state database not set")
}
t.client = tmcli.New(t.node)
t.failMonitor = newFailMonitor(t.Logger, t.node.ConsensusState().Wait)
t.failMonitor = newFailMonitor(t.ctx, t.Logger, t.node.ConsensusState().Wait)

return nil
}
Expand Down