Skip to content

fix: return err instead of nil on saveSnapshot failure#409

Open
Qian-Cheng-nju wants to merge 3 commits intolni:masterfrom
specula-org:fix/silent-error-in-save-snapshot
Open

fix: return err instead of nil on saveSnapshot failure#409
Qian-Cheng-nju wants to merge 3 commits intolni:masterfrom
specula-org:fix/silent-error-in-save-snapshot

Conversation

@Qian-Cheng-nju
Copy link
Copy Markdown

saveRaftState and saveSnapshots in internal/logdb/db.go have return nil where return err was intended:

if err := r.saveSnapshot(wb, ud); err != nil {
    return nil  // should be return err
}

When saveSnapshot fails (e.g. disk I/O error in listSnapshots), return nil causes the function to exit early without calling saveEntries or CommitWriteBatch, silently dropping the entire batch of raft log entries. The caller receives a nil error and assumes the write succeeded.

The same commit (0d704a2) has a third call site in importSnapshot that correctly writes return err.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant