Skip to content

Commit 4c8f61a

Browse files
authored
reduce error report for non-error (#638)
only error about "failed to take snapshot" when error isn't "nothing new to snapshot"
1 parent a2e8778 commit 4c8f61a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

snapshot.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
package raft
55

66
import (
7+
"errors"
78
"fmt"
89
"io"
910
"time"
1011

11-
"github.com/hashicorp/go-metrics/compat"
12+
metrics "github.com/hashicorp/go-metrics/compat"
1213
)
1314

1415
// SnapshotMeta is for metadata of a snapshot.
@@ -79,16 +80,16 @@ func (r *Raft) runSnapshots() {
7980
}
8081

8182
// Trigger a snapshot
82-
if _, err := r.takeSnapshot(); err != nil {
83+
if _, err := r.takeSnapshot(); err != nil && !errors.Is(err, ErrNothingNewToSnapshot) {
8384
r.logger.Error("failed to take snapshot", "error", err)
8485
}
8586

8687
case future := <-r.userSnapshotCh:
8788
// User-triggered, run immediately
8889
id, err := r.takeSnapshot()
89-
if err != nil {
90+
if err != nil && !errors.Is(err, ErrNothingNewToSnapshot) {
9091
r.logger.Error("failed to take snapshot", "error", err)
91-
} else {
92+
} else if err == nil {
9293
future.opener = func() (*SnapshotMeta, io.ReadCloser, error) {
9394
return r.snapshots.Open(id)
9495
}

0 commit comments

Comments
 (0)