From c127ba20f7530f8cd970b8c04a07dd2545476559 Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Fri, 10 Sep 2021 16:49:28 +0100 Subject: [PATCH] Raft worker errors In order to improve readability of why a raft worker is restarting, the following introduces logging error messages. The problem isn't helped by the masked ErrStartTimeout waiting for a new raft channel. As the catacomb is killed by the ErrStartTimeout, we loose the original error message. We should revisit if this is the best way to do this! --- worker/raft/worker.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/worker/raft/worker.go b/worker/raft/worker.go index 53e4f980ba2..c435b11c810 100644 --- a/worker/raft/worker.go +++ b/worker/raft/worker.go @@ -310,6 +310,9 @@ func (w *Worker) loop(raftConfig *raft.Config) (loopErr error) { rawLogStore, err := NewLogStore(w.config.StorageDir, syncMode) if err != nil { + // Required logging, as ErrStartTimeout can mask the underlying error + // and we never know the original failure. + w.config.Logger.Errorf("Failed to setup raw log store, err: %v", err) return errors.Trace(err) } @@ -326,11 +329,17 @@ func (w *Worker) loop(raftConfig *raft.Config) (loopErr error) { } snapshotStore, err := NewSnapshotStore(w.config.StorageDir, snapshotRetention, w.config.Logger) if err != nil { + // Required logging, as ErrStartTimeout can mask the underlying error + // and we never know the original failure. + w.config.Logger.Errorf("Failed to setup snapshot store, err: %v", err) return errors.Trace(err) } r, err := raft.NewRaft(raftConfig, w.config.FSM, logStore, rawLogStore, snapshotStore, w.config.Transport) if err != nil { + // Required logging, as ErrStartTimeout can mask the underlying error + // and we never know the original failure. + w.config.Logger.Errorf("Failed to setup raft instance, err: %v", err) return errors.Trace(err) } defer func() {