From 9a0ec84953ef4ae2ee49bfa7848aaa3ebe532b1d Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 16 Mar 2023 17:41:06 +0200 Subject: [PATCH] shut down the index if there is an error during head processing --- chain/index/msgindex.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chain/index/msgindex.go b/chain/index/msgindex.go index 16b47616f..534a11cd4 100644 --- a/chain/index/msgindex.go +++ b/chain/index/msgindex.go @@ -314,8 +314,11 @@ func (x *msgIndex) background(ctx context.Context) { case <-x.sema: err := x.processHeadChanges(ctx) if err != nil { - // TODO should we shut down the index altogether? we just log for now. - log.Errorf("error processing head change notifications: %s", err) + // we can't rely on an inconsistent index, so shut it down. + log.Errorf("error processing head change notifications: %s; shutting down message index", err) + if err2 := x.Close(); err2 != nil { + log.Errorf("error shutting down index: %s", err2) + } } case <-ctx.Done():