2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00
restic/internal/archiver
Michael Eischer bdf7ba20cb archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError
The Save methods of the BlobSaver, FileSaver and TreeSaver return early
on when the archiver is stopped due to an error. For that they select on
both the tomb.Dying() and context.Done() channels, which can lead to a
race condition when the tomb is killed due to an error: The tomb first
closes its Dying channel before canceling all child contexts.
Archiver.SaveDir only aborts its execution once the context was
canceled. When the tomb killing is paused between closing its Dying
channel and canceling the child contexts, this lets the
FileSaver/TreeSaver.Save methods return immediately, however, ScanDir
still reads further files causing the test case to fail.

As a killed tomb always cancels all child contexts and as the Savers
always use a context bound to the tomb, it is sufficient to just use
context.Done() as escape hatch in the Save functions. This fixes the
mismatch between SaveDir and Save.

Adjust the tests to use contexts bound to the tomb for all interactions
with the Savers.
2020-04-13 18:23:17 +02:00
..
archiver_test.go Fix running tests on a SELinux enabled system 2020-03-01 20:23:22 +01:00
archiver_unix_test.go archiver: Use untyped constants for testing FileInfo 2019-05-05 14:57:38 +02:00
archiver_windows_test.go archiver: Use untyped constants for testing FileInfo 2019-05-05 14:57:38 +02:00
archiver.go Merge pull request #2589 from greatroar/no-stable-sort 2020-03-01 19:40:28 +01:00
blob_saver_test.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
blob_saver.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
buffer.go archiver: Improve buffer pool 2018-04-30 15:13:28 +02:00
doc.go archiver: Add high-level documentation 2018-05-12 23:55:54 +02:00
file_saver_test.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
file_saver.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
index_uploader.go Add new archiver code 2018-04-25 14:42:45 +02:00
scanner_test.go scanner: Use context only for cancellation 2018-09-08 18:53:12 +02:00
scanner.go Merge duplicated readdir functionality 2020-02-26 11:05:38 +01:00
testing_test.go Fix formatting for gofmt with Go 1.11 2018-08-31 21:10:26 +02:00
testing.go Remove remnant of Go 1.9 compatibility code from tests 2020-02-26 22:23:38 +01:00
tree_saver_test.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
tree_saver.go archiver: Fix race condition triggered by TestArchiverAbortEarlyOnError 2020-04-13 18:23:17 +02:00
tree_test.go Assert that archiver.Tree implements fmt.Stringer 2020-02-26 11:05:38 +01:00
tree.go Merge duplicated readdir functionality 2020-02-26 11:05:38 +01:00