restic/internal/archiver
Michael Eischer ce89018902 Fix data race in blob_saver
After the `BlobSaver` job is submitted, the buffer can be released and
reused by another `FileSaver` even before `BlobSaver.Save` returns. That
FileSaver will the change `buf.Data` leading to wrong backup statistics.

Found by `go test -race ./...`:

WARNING: DATA RACE
Write at 0x00c0000784a0 by goroutine 41:
  github.com/restic/restic/internal/archiver.(*FileSaver).saveFile()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:176 +0x789
  github.com/restic/restic/internal/archiver.(*FileSaver).worker()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:242 +0x2af
  github.com/restic/restic/internal/archiver.NewFileSaver.func2()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:88 +0x5d
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /home/michael/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x91

Previous read at 0x00c0000784a0 by goroutine 29:
  github.com/restic/restic/internal/archiver.(*BlobSaver).Save()
      /home/michael/Projekte/restic/restic/internal/archiver/blob_saver.go:57 +0x1dd
  github.com/restic/restic/internal/archiver.(*BlobSaver).Save-fm()
      <autogenerated>:1 +0xac
  github.com/restic/restic/internal/archiver.(*FileSaver).saveFile()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:191 +0x855
  github.com/restic/restic/internal/archiver.(*FileSaver).worker()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:242 +0x2af
  github.com/restic/restic/internal/archiver.NewFileSaver.func2()
      /home/michael/Projekte/restic/restic/internal/archiver/file_saver.go:88 +0x5d
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /home/michael/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x91
2022-07-03 14:47:53 +02:00
..
archiver.go archiver: Reduce tree saver concurrency 2022-07-02 22:42:34 +02:00
archiver_test.go repository: Rework blob saving to use an async pack uploader 2022-07-02 22:42:34 +02:00
archiver_unix_test.go add go:build headers everywhere 2022-03-28 22:23:47 +02:00
archiver_windows_test.go add go:build headers everywhere 2022-03-28 22:23:47 +02:00
blob_saver.go Fix data race in blob_saver 2022-07-03 14:47:53 +02:00
blob_saver_test.go Return real size from SaveBlob 2022-07-02 18:55:12 +02:00
buffer.go archiver: Remove cleanup goroutine from BufferPool 2022-05-29 17:09:16 +02:00
doc.go archiver: Add high-level documentation 2018-05-12 23:55:54 +02:00
file_saver.go Print number of bytes added to the repo 2022-07-02 18:55:12 +02:00
file_saver_test.go archiver: remove tomb usage 2022-06-05 15:47:52 +02:00
scanner.go backup/scanner: Fix total size for overlapping targets 2021-01-29 11:31:36 +01:00
scanner_test.go backup/scanner: Fix total size for overlapping targets 2021-01-29 11:31:36 +01:00
testing.go archiver: Fix test 2022-03-28 22:09:49 +02:00
testing_test.go Move internal/fs.TestChdir to internal/test.Chdir 2020-09-17 10:43:33 +02:00
tree.go archiver/tree: Introduce functions Leaf() and NodeNames() 2021-01-29 11:11:28 +01:00
tree_saver.go archiver: remove tomb usage 2022-06-05 15:47:52 +02:00
tree_saver_test.go archiver: remove tomb usage 2022-06-05 15:47:52 +02:00
tree_test.go Remove a few redundant type specifiers 2020-10-06 14:55:13 +02:00