Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion br/pkg/streamhelper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 35,
shard_count = 36,
deps = [
":streamhelper",
"//br/pkg/errors",
Expand Down
5 changes: 1 addition & 4 deletions br/pkg/streamhelper/flush_subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package streamhelper

import (
"context"
"io"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -278,12 +277,10 @@ func (s *subscription) listenOver(ctx context.Context, cli eventStream) {
// Shall we use RecvMsg for better performance?
// Note that the spans.Full requires the input slice be immutable.
msg, err := cli.Recv()
failpoint.InjectCall("listen_flush_stream", s.storeID, &err)
if err != nil {
logutil.CL(ctx).Info("Listen stopped.",
zap.Uint64("store", storeID), logutil.ShortError(err))
if err == io.EOF || err == context.Canceled || status.Code(err) == codes.Canceled {
return
}
s.emitError(errors.Annotatef(err, "while receiving from store id %d", storeID))
return
}
Expand Down
26 changes: 26 additions & 0 deletions br/pkg/streamhelper/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/br/pkg/streamhelper"
"github.com/pingcap/tidb/br/pkg/streamhelper/spans"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -240,3 +241,28 @@ func TestSomeOfStoreUnsupported(t *testing.T) {
req.NoError(err)
req.Equal(cp, s.MinValue())
}

func TestEncounterError(t *testing.T) {
req := require.New(t)
ctx := context.Background()
c := createFakeCluster(t, 4, true)
c.splitAndScatter("0001", "0002", "0003", "0008", "0009", "0010", "0100", "0956", "1000")

sub := streamhelper.NewSubscriber(c, c)
installSubscribeSupport(c)
req.NoError(sub.UpdateStoreTopology(ctx))

o := new(sync.Once)
failpoint.EnableCall("github.com/pingcap/tidb/br/pkg/streamhelper/listen_flush_stream", func(storeID uint64, err *error) {
o.Do(func() {
*err = context.Canceled
})
})

c.flushAll()
require.Eventually(t, func() bool {
return sub.PendingErrors() != nil
}, 3*time.Second, 100*time.Millisecond)
sub.HandleErrors(context.Background())
require.NoError(t, sub.PendingErrors())
}
Loading