diff --git a/go/vt/vtgate/vstream_manager.go b/go/vt/vtgate/vstream_manager.go index 79cd9be587a..ffb8989ca5d 100644 --- a/go/vt/vtgate/vstream_manager.go +++ b/go/vt/vtgate/vstream_manager.go @@ -53,6 +53,10 @@ type vstreamManager struct { // maxSkewTimeoutSeconds is the maximum allowed skew between two streams when the MinimizeSkew flag is set const maxSkewTimeoutSeconds = 10 * 60 +// tabletPickerContextTimeout is the timeout for the child context used to select candidate tablets +// for a vstream +const tabletPickerContextTimeout = 90 * time.Second + // vstream contains the metadata for one VStream request. type vstream struct { // mu protects parts of vgtid, the semantics of a send, and journaler. @@ -500,8 +504,8 @@ func (vs *vstream) streamFromTablet(ctx context.Context, sgtid *binlogdatapb.Sha } // Create a child context with a stricter timeout when picking a tablet. - // This will prevent hanging in the case no tablets are found - tpCtx, tpCancel := context.WithTimeout(context.Background(), 90*time.Second) + // This will prevent hanging in the case no tablets are found. + tpCtx, tpCancel := context.WithTimeout(ctx, tabletPickerContextTimeout) defer tpCancel() tablet, err := tp.PickForStreaming(tpCtx) diff --git a/go/vt/vtgate/vstream_manager_test.go b/go/vt/vtgate/vstream_manager_test.go index 55575be1db4..4c1e9ec6764 100644 --- a/go/vt/vtgate/vstream_manager_test.go +++ b/go/vt/vtgate/vstream_manager_test.go @@ -455,7 +455,7 @@ func TestVStreamRetriableErrors(t *testing.T) { vsm := newTestVStreamManager(ctx, hc, st, cells[0]) // Always have the local cell tablet error so it's ignored on retry and we pick the other one - // if the error requires ignoring the tablet on retry + // if the error requires ignoring the tablet on retry. sbc0.AddVStreamEvents(nil, vterrors.Errorf(tcase.code, tcase.msg)) if tcase.ignoreTablet {