Skip to content

Commit

Permalink
backupccl: always track opened writer
Browse files Browse the repository at this point in the history
Previously we would do things -- like wrap the opened writer with an encryption shim --
after opening the writer but before storing it in the sink. This could mean that if the
sink opened a writer, but failed to save it, and was then closed it would fail to close
the writer. This changes that, so that as soon as the writer is opened it is saved and
then if it is later wrapped, saved again, to ensure that we cannot lose track of any
successfully opened writer.

Fixes: #103597.

Release note: none.
  • Loading branch information
dt committed Jun 1, 2023
1 parent 7ed8248 commit 64dea46
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/ccl/backupccl/file_sst_sink.go
Expand Up @@ -154,14 +154,14 @@ func (s *fileSSTSink) open(ctx context.Context) error {
if err != nil {
return err
}
s.out = w
if s.conf.enc != nil {
var err error
w, err = storageccl.EncryptingWriter(w, s.conf.enc.Key)
e, err := storageccl.EncryptingWriter(w, s.conf.enc.Key)
if err != nil {
return err
}
s.out = e
}
s.out = w
s.sst = storage.MakeBackupSSTWriter(ctx, s.dest.Settings(), s.out)

return nil
Expand Down

0 comments on commit 64dea46

Please sign in to comment.