diff --git a/br/pkg/backup/BUILD.bazel b/br/pkg/backup/BUILD.bazel index a752836cdbe80..a513511cdf8ff 100644 --- a/br/pkg/backup/BUILD.bazel +++ b/br/pkg/backup/BUILD.bazel @@ -68,7 +68,7 @@ go_test( embed = [":backup"], flaky = True, race = "on", - shard_count = 14, + shard_count = 15, deps = [ "//br/pkg/conn", "//br/pkg/gluetidb/mock", diff --git a/br/pkg/backup/store.go b/br/pkg/backup/store.go index 0015efa0681d0..03e68c54ce220 100644 --- a/br/pkg/backup/store.go +++ b/br/pkg/backup/store.go @@ -79,6 +79,7 @@ func (trecv *timeoutRecv) Refresh() { func (trecv *timeoutRecv) Stop() { close(trecv.refresh) trecv.wg.Wait() + trecv.cancel(nil) } var TimeoutOneResponse = time.Hour diff --git a/br/pkg/backup/store_test.go b/br/pkg/backup/store_test.go index 9ad928f01a635..d4e1011e1a386 100644 --- a/br/pkg/backup/store_test.go +++ b/br/pkg/backup/store_test.go @@ -96,3 +96,13 @@ func TestTimeoutRecvCancel(t *testing.T) { cancel() trecv.wg.Wait() } + +func TestTimeoutRecvCanceled(t *testing.T) { + ctx := context.Background() + cctx, cancel := context.WithCancel(ctx) + defer cancel() + + tctx, trecv := StartTimeoutRecv(cctx, time.Hour) + trecv.Stop() + require.Equal(t, "context canceled", tctx.Err().Error()) +}