Skip to content

Commit beb60eb

Browse files
committed
cloud: fix usage of CombineErrors
Previously, nodelocal and cloud contained CombineErrors calls that were passing the secondary error as the first argument. This is undesirable because only the first argument to CombineErrors is part of the causal error chain. The instance of this in WriteFile was uncovered by a fault injection test. An injected error was being unexpectedly retried because Close was failing with a context cancelled error. Release note: none Epic: CRDB-53946
1 parent c1e847b commit beb60eb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/blobs/local_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (l localWriter) Close() error {
8484

8585
syncErr := l.f.Sync()
8686
closeErr := l.f.Close()
87-
if err := errors.CombineErrors(closeErr, syncErr); err != nil {
87+
if err := errors.CombineErrors(syncErr, closeErr); err != nil {
8888
return err
8989
}
9090
// Finally put the file to its final location.

pkg/cloud/cloud_io.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func WriteFile(ctx context.Context, dest ExternalStorage, basename string, src i
454454
_, err = io.Copy(w, src)
455455
if err != nil {
456456
cancel()
457-
return errors.CombineErrors(w.Close(), err)
457+
return errors.CombineErrors(err, w.Close())
458458
}
459459
return errors.Wrap(w.Close(), "closing object")
460460
}

0 commit comments

Comments
 (0)