Skip to content

Commit

Permalink
Merge pull request #9683 from gyuho/sss
Browse files Browse the repository at this point in the history
*: clarify missing snapshot file error message/warning
  • Loading branch information
gyuho authored May 2, 2018
2 parents cc44c08 + 47ab4e2 commit 62dfb89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions etcdserver/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func newBackend(cfg ServerConfig) backend.Backend {
func openSnapshotBackend(cfg ServerConfig, ss *raftsnap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) {
snapPath, err := ss.DBFilePath(snapshot.Metadata.Index)
if err != nil {
return nil, fmt.Errorf("database snapshot file path error: %v", err)
return nil, fmt.Errorf("failed to find database snapshot file (%v)", err)
}
if err := os.Rename(snapPath, cfg.backendPath()); err != nil {
return nil, fmt.Errorf("rename snapshot file error: %v", err)
return nil, fmt.Errorf("failed to rename database snapshot file (%v)", err)
}
return openBackend(cfg), nil
}
Expand Down
11 changes: 10 additions & 1 deletion raftsnap/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,18 @@ func (s *Snapshotter) DBFilePath(id uint64) (string, error) {
if _, err := fileutil.ReadDir(s.dir); err != nil {
return "", err
}
if fn := s.dbFilePath(id); fileutil.Exist(fn) {
fn := s.dbFilePath(id)
if fileutil.Exist(fn) {
return fn, nil
}
if s.lg != nil {
s.lg.Warn(
"failed to find [SNAPSHOT-INDEX].snap.db",
zap.Uint64("snapshot-index", id),
zap.String("snapshot-file-path", fn),
zap.Error(ErrNoDBSnapshot),
)
}
return "", ErrNoDBSnapshot
}

Expand Down

0 comments on commit 62dfb89

Please sign in to comment.