Treat fsync errors during save as SaveRejection errors.

PiperOrigin-RevId: 241055485
Change-Id: I70259e9fef59bdf9733b35a2cd3319359449dd45
This commit is contained in:
Nicolas Lacasse
2019-03-29 14:48:16 -07:00
committed by Shentubot
parent d11ef20a93
commit e8fef3d873
+8 -5
View File
@@ -365,12 +365,15 @@ func (ts *TaskSet) flushWritesToFiles(ctx context.Context) error {
syncErr := desc.file.Fsync(ctx, 0, fs.FileMaxOffset, fs.SyncAll)
if err := fs.SaveFileFsyncError(syncErr); err != nil {
name, _ := desc.file.Dirent.FullName(nil /* root */)
// Wrapping this error not only allows
// for a more useful message, but is
// required to distinguish Fsync errors
// from state file errors in
// Wrap this error in ErrSaveRejection
// so that it will trigger a save
// error, rather than a panic. This
// also allows us to distinguish Fsync
// errors from state file errors in
// state.Save.
return fmt.Errorf("%q was not sufficiently synced: %v", name, err)
return fs.ErrSaveRejection{
Err: fmt.Errorf("%q was not sufficiently synced: %v", name, err),
}
}
}
}