Skip to content

Commit 2a4be79

Browse files
craig[bot]jeffswenson
andcommitted
Merge #153182
153182: cloud: fix usage of CombineErrors r=jeffswenson a=jeffswenson 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 Co-authored-by: Jeff Swenson <[email protected]>
2 parents dec7e21 + beb60eb commit 2a4be79

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
@@ -455,7 +455,7 @@ func WriteFile(ctx context.Context, dest ExternalStorage, basename string, src i
455455
_, err = io.Copy(w, src)
456456
if err != nil {
457457
cancel()
458-
return errors.CombineErrors(w.Close(), err)
458+
return errors.CombineErrors(err, w.Close())
459459
}
460460
return errors.Wrap(w.Close(), "closing object")
461461
}

0 commit comments

Comments
 (0)