@@ -90,7 +90,7 @@ func (n *checkExternalConnectionNode) startExec(params runParams) error {
90
90
time .Duration (tree .MustBeDInt (nanos )),
91
91
))
92
92
}
93
- n .rows = make (chan tree.Datums , int64 ( len (sqlInstanceIDs )) * n .params . Concurrency )
93
+ n .rows = make (chan tree.Datums , len (sqlInstanceIDs )* getCloudCheckConcurrency ( n .params ) )
94
94
rowWriter := NewCallbackResultWriter (func (ctx context.Context , row tree.Datums ) error {
95
95
// collapse the two pairs of bytes+time to a single string rate each.
96
96
res := make (tree.Datums , len (row )- 1 )
@@ -103,13 +103,15 @@ func (n *checkExternalConnectionNode) startExec(params runParams) error {
103
103
return nil
104
104
})
105
105
106
- grp := ctxgroup . WithContext ( params . ctx )
107
- n .execGrp = grp
108
- grp .GoCtx (func (ctx context.Context ) error {
106
+ workerStarted := make ( chan struct {} )
107
+ n .execGrp = ctxgroup . WithContext ( params . ctx )
108
+ n . execGrp .GoCtx (func (ctx context.Context ) error {
109
109
// Derive a separate tracing span since the planning one will be
110
110
// finished when the main goroutine exits from startExec.
111
111
ctx , span := tracing .ChildSpan (ctx , "CheckExternalConnection-execution" )
112
112
defer span .Finish ()
113
+ // Unblock the main goroutine after having created the tracing span.
114
+ close (workerStarted )
113
115
114
116
recv := MakeDistSQLReceiver (
115
117
ctx ,
@@ -129,6 +131,14 @@ func (n *checkExternalConnectionNode) startExec(params runParams) error {
129
131
return nil
130
132
})
131
133
134
+ // Block until the worker goroutine has started. This allows us to guarantee
135
+ // that params.ctx contains a tracing span that hasn't been finished.
136
+ // TODO(yuzefovich): this is a bit hacky. The issue is that
137
+ // planNodeToRowSource has already created a new tracing span for this
138
+ // checkExternalConnectionNode and has updated params.ctx accordingly; then,
139
+ // if the query is canceled before the worker goroutine starts, the tracing
140
+ // span is finished, yet it will have already been captured by the ctxgroup.
141
+ <- workerStarted
132
142
return nil
133
143
}
134
144
0 commit comments