From 18fccb59955230363af37415c105030580256181 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 25 Feb 2021 21:43:08 +0100 Subject: [PATCH 1/2] backup: In case of error also Wait() for terminal goroutine This prevents a race condition where the final summary message can get lost. --- changelog/unreleased/pull-3305 | 7 +++++++ cmd/restic/cmd_backup.go | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/pull-3305 diff --git a/changelog/unreleased/pull-3305 b/changelog/unreleased/pull-3305 new file mode 100644 index 000000000..edc640230 --- /dev/null +++ b/changelog/unreleased/pull-3305 @@ -0,0 +1,7 @@ +Bugfix: In case of error also Wait() for terminal goroutine + +This prevents a race condition where the final summary message is +lost. When using --json output it happened from time to time that the +summary output was missing. + +https://github.com/restic/restic/pull/3305 \ No newline at end of file diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index ef03884ab..29169a018 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -60,11 +60,11 @@ Exit status is 3 if some source data could not be read (incomplete snapshot crea t.Go(func() error { term.Run(t.Context(globalOptions.ctx)); return nil }) err := runBackup(backupOptions, globalOptions, term, args) - if err != nil { - return err - } t.Kill(nil) - return t.Wait() + if werr := t.Wait(); werr != nil { + panic(fmt.Sprintf("term.Run() returned err: %v", err)) + } + return err }, } From f9c581f219098196218fcc58d99ea9b11126e973 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 8 Mar 2021 22:11:05 +0100 Subject: [PATCH 2/2] Tweak changelog --- changelog/unreleased/pull-3305 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/changelog/unreleased/pull-3305 b/changelog/unreleased/pull-3305 index edc640230..da34ea95d 100644 --- a/changelog/unreleased/pull-3305 +++ b/changelog/unreleased/pull-3305 @@ -1,7 +1,6 @@ -Bugfix: In case of error also Wait() for terminal goroutine +Bugfix: Fix possibly missing backup summary of json output in case of error -This prevents a race condition where the final summary message is -lost. When using --json output it happened from time to time that the -summary output was missing. +When using --json output it happened from time to time that the summary output +was missing in case an error occurred. This has been fixed. -https://github.com/restic/restic/pull/3305 \ No newline at end of file +https://github.com/restic/restic/pull/3305