-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathoutbox_test.go
604 lines (550 loc) · 19.9 KB
/
outbox_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package flowinfra
import (
"context"
"fmt"
"io"
"net"
"sync"
"testing"
"time"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/rpc"
"github.com/cockroachdb/cockroach/pkg/rpc/nodedialer"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/errors"
)
// staticAddressResolver maps StaticNodeID to the given address.
func staticAddressResolver(addr net.Addr) nodedialer.AddressResolver {
return func(nodeID roachpb.NodeID) (net.Addr, error) {
if nodeID == execinfra.StaticNodeID {
return addr, nil
}
return nil, errors.Errorf("node %d not found", nodeID)
}
}
func TestOutbox(t *testing.T) {
defer leaktest.AfterTest(t)()
// Create a mock server that the outbox will connect and push rows to.
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
clusterID, mockServer, addr, err := execinfrapb.StartMockDistSQLServer(clock, stopper, execinfra.StaticNodeID)
if err != nil {
t.Fatal(err)
}
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(context.Background())
clientRPC := rpc.NewInsecureTestingContextWithClusterID(clock, stopper, clusterID)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
NodeDialer: nodedialer.New(clientRPC, staticAddressResolver(addr)),
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
streamID := execinfrapb.StreamID(42)
outbox := NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
outbox.Init(rowenc.OneIntCol)
var outboxWG sync.WaitGroup
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Start the outbox. This should cause the stream to connect, even though
// we're not sending any rows.
outbox.Start(ctx, &outboxWG, cancel)
// Start a producer. It will send one row 0, then send rows -1 until a drain
// request is observed, then send row 2 and some metadata.
producerC := make(chan error)
go func() {
producerC <- func() error {
row := rowenc.EncDatumRow{
rowenc.DatumToEncDatum(types.Int, tree.NewDInt(tree.DInt(0))),
}
if consumerStatus := outbox.Push(row, nil /* meta */); consumerStatus != execinfra.NeedMoreRows {
return errors.Errorf("expected status: %d, got: %d", execinfra.NeedMoreRows, consumerStatus)
}
// Send rows until the drain request is observed.
for {
row = rowenc.EncDatumRow{
rowenc.DatumToEncDatum(types.Int, tree.NewDInt(tree.DInt(-1))),
}
consumerStatus := outbox.Push(row, nil /* meta */)
if consumerStatus == execinfra.DrainRequested {
break
}
if consumerStatus == execinfra.ConsumerClosed {
return errors.Errorf("consumer closed prematurely")
}
}
// Now send another row that the outbox will discard.
row = rowenc.EncDatumRow{rowenc.DatumToEncDatum(types.Int, tree.NewDInt(tree.DInt(2)))}
if consumerStatus := outbox.Push(row, nil /* meta */); consumerStatus != execinfra.DrainRequested {
return errors.Errorf("expected status: %d, got: %d", execinfra.NeedMoreRows, consumerStatus)
}
// Send some metadata.
outbox.Push(nil /* row */, &execinfrapb.ProducerMetadata{Err: errors.Errorf("meta 0")})
outbox.Push(nil /* row */, &execinfrapb.ProducerMetadata{Err: errors.Errorf("meta 1")})
// Send the termination signal.
outbox.ProducerDone()
return nil
}()
}()
// Wait for the outbox to connect the stream.
streamNotification := <-mockServer.InboundStreams
serverStream := streamNotification.Stream
// Consume everything that the outbox sends on the stream.
var decoder StreamDecoder
var rows rowenc.EncDatumRows
var metas []execinfrapb.ProducerMetadata
drainSignalSent := false
for {
msg, err := serverStream.Recv()
if err != nil {
if err == io.EOF {
break
}
t.Fatal(err)
}
err = decoder.AddMessage(context.Background(), msg)
if err != nil {
t.Fatal(err)
}
rows, metas = testGetDecodedRows(t, &decoder, rows, metas)
// Eliminate the "-1" rows, that were sent before the producer found out
// about the draining.
last := -1
for i := 0; i < len(rows); i++ {
if rows[i].String(rowenc.OneIntCol) != "[-1]" {
last = i
continue
}
for j := i; j < len(rows); j++ {
if rows[j].String(rowenc.OneIntCol) == "[-1]" {
continue
}
rows[i] = rows[j]
i = j
last = j
break
}
}
rows = rows[0 : last+1]
// After we receive one row, we're going to ask the producer to drain.
if !drainSignalSent && len(rows) > 0 {
sig := execinfrapb.ConsumerSignal{DrainRequest: &execinfrapb.DrainRequest{}}
if err := serverStream.Send(&sig); err != nil {
t.Fatal(err)
}
drainSignalSent = true
}
}
if err := <-producerC; err != nil {
t.Fatalf("%+v", err)
}
if len(metas) != 2 {
t.Fatalf("expected 2 metadata records, got: %d", len(metas))
}
for i, m := range metas {
expectedStr := fmt.Sprintf("meta %d", i)
if !testutils.IsError(m.Err, expectedStr) {
t.Fatalf("expected: %q, got: %q", expectedStr, m.Err.Error())
}
}
str := rows.String(rowenc.OneIntCol)
expected := "[[0]]"
if str != expected {
t.Errorf("invalid results: %s, expected %s'", str, expected)
}
// The outbox should shut down since the producer closed.
outboxWG.Wait()
// Signal the server to shut down the stream.
streamNotification.Donec <- nil
}
// Test that an outbox connects its stream as soon as possible (i.e. before
// receiving any rows). This is important, since there's a timeout on waiting on
// the server-side for the streams to be connected.
func TestOutboxInitializesStreamBeforeReceivingAnyRows(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
clusterID, mockServer, addr, err := execinfrapb.StartMockDistSQLServer(clock, stopper, execinfra.StaticNodeID)
if err != nil {
t.Fatal(err)
}
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(context.Background())
clientRPC := rpc.NewInsecureTestingContextWithClusterID(clock, stopper, clusterID)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
NodeDialer: nodedialer.New(clientRPC, staticAddressResolver(addr)),
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
streamID := execinfrapb.StreamID(42)
outbox := NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
var outboxWG sync.WaitGroup
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
outbox.Init(rowenc.OneIntCol)
// Start the outbox. This should cause the stream to connect, even though
// we're not sending any rows.
outbox.Start(ctx, &outboxWG, cancel)
streamNotification := <-mockServer.InboundStreams
serverStream := streamNotification.Stream
producerMsg, err := serverStream.Recv()
if err != nil {
t.Fatal(err)
}
if producerMsg.Header == nil {
t.Fatal("missing header")
}
if producerMsg.Header.FlowID != flowCtx.ID || producerMsg.Header.StreamID != streamID {
t.Fatalf("wrong header: %v", producerMsg)
}
// Signal the server to shut down the stream. This should also prompt the
// outbox (the client) to terminate its loop.
streamNotification.Donec <- nil
outboxWG.Wait()
}
// Test that the outbox responds to the consumer shutting down in an unexpected
// way by closing.
func TestOutboxClosesWhenConsumerCloses(t *testing.T) {
defer leaktest.AfterTest(t)()
testCases := []struct {
// When set, the outbox will establish the stream with a FlowRpc call. When
// not set, the consumer will establish the stream with RunSyncFlow.
outboxIsClient bool
// Only takes effect with outboxIsClient is set. When set, the consumer
// (i.e. the server) returns an error from RunSyncFlow. This error will be
// translated into a grpc error received by the client (i.e. the outbox) in
// its stream.Recv()) call. Otherwise, the client doesn't return an error
// (and the outbox should receive io.EOF).
serverReturnsError bool
}{
{outboxIsClient: true, serverReturnsError: false},
{outboxIsClient: true, serverReturnsError: true},
{outboxIsClient: false},
}
for _, tc := range testCases {
t.Run("", func(t *testing.T) {
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
clusterID, mockServer, addr, err := execinfrapb.StartMockDistSQLServer(clock, stopper, execinfra.StaticNodeID)
if err != nil {
t.Fatal(err)
}
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(context.Background())
clientRPC := rpc.NewInsecureTestingContextWithClusterID(clock, stopper, clusterID)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
NodeDialer: nodedialer.New(clientRPC, staticAddressResolver(addr)),
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
streamID := execinfrapb.StreamID(42)
var outbox *Outbox
var wg sync.WaitGroup
var expectedErr error
consumerReceivedMsg := make(chan struct{})
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if tc.outboxIsClient {
outbox = NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
outbox.Init(rowenc.OneIntCol)
outbox.Start(ctx, &wg, cancel)
// Wait for the outbox to connect the stream.
streamNotification := <-mockServer.InboundStreams
// Wait for the consumer to receive the header message that the outbox
// sends on start. If we don't wait, the consumer returning from the
// FlowStream() RPC races with the outbox sending the header msg and the
// send might get an io.EOF error.
if _, err := streamNotification.Stream.Recv(); err != nil {
t.Errorf("expected err: %q, got %v", expectedErr, err)
}
// Have the server return from the FlowStream call. This should prompt the
// outbox to finish.
if tc.serverReturnsError {
expectedErr = errors.Errorf("FlowStream server error")
} else {
expectedErr = nil
}
streamNotification.Donec <- expectedErr
} else {
// We're going to perform a RunSyncFlow call and then have the client
// cancel the call's context.
conn, err := flowCtx.Cfg.NodeDialer.Dial(ctx, execinfra.StaticNodeID, rpc.DefaultClass)
if err != nil {
t.Fatal(err)
}
client := execinfrapb.NewDistSQLClient(conn)
var outStream execinfrapb.DistSQL_RunSyncFlowClient
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
expectedErr = errors.Errorf("context canceled")
go func() {
outStream, err = client.RunSyncFlow(ctx)
if err != nil {
t.Error(err)
}
// Check that Recv() receives an error once the context is canceled.
// Perhaps this is not terribly important to test; one can argue that
// the client should either not be Recv()ing after it canceled the
// ctx or that it otherwise should otherwise be aware of the
// cancellation when processing the results, but I've put it here
// because bidi streams are confusing and this provides some
// information.
for {
_, err := outStream.Recv()
if err == nil {
consumerReceivedMsg <- struct{}{}
continue
}
if !testutils.IsError(err, expectedErr.Error()) {
t.Errorf("expected err: %q, got %v", expectedErr, err)
}
break
}
}()
// Wait for the consumer to connect.
call := <-mockServer.RunSyncFlowCalls
outbox = NewOutboxSyncFlowStream(call.Stream)
outbox.SetFlowCtx(&execinfra.FlowCtx{
Cfg: &execinfra.ServerConfig{
Settings: cluster.MakeTestingClusterSettings(),
Stopper: stopper,
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
})
outbox.Init(rowenc.OneIntCol)
// In a RunSyncFlow call, the outbox runs under the call's context.
outbox.Start(call.Stream.Context(), &wg, cancel)
// Wait for the consumer to receive the header message that the outbox
// sends on start. If we don't wait, the context cancellation races with
// the outbox sending the header msg; if the cancellation makes it to
// the outbox right as the outbox is trying to send the header, the
// outbox might finish with a "the stream has been done" error instead
// of "context canceled".
<-consumerReceivedMsg
// cancel the RPC's context. This is how a streaming RPC client can inform
// the server that it's done. We expect the outbox to finish.
cancel()
defer func() {
// Allow the RunSyncFlow RPC to finish.
call.Donec <- nil
}()
}
wg.Wait()
if expectedErr == nil {
if outbox.err != nil {
t.Fatalf("unexpected outbox.err: %s", outbox.err)
}
} else {
// We use error string comparison because we actually expect a grpc
// error wrapping the expected error.
if !testutils.IsError(outbox.err, expectedErr.Error()) {
t.Fatalf("expected err: %q, got %v", expectedErr, outbox.err)
}
}
})
}
}
// Test Outbox cancels flow context when FlowStream returns a non-nil error.
func TestOutboxCancelsFlowOnError(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
clusterID, mockServer, addr, err := execinfrapb.StartMockDistSQLServer(clock, stopper, execinfra.StaticNodeID)
if err != nil {
t.Fatal(err)
}
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(context.Background())
clientRPC := rpc.NewInsecureTestingContextWithClusterID(clock, stopper, clusterID)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
NodeDialer: nodedialer.New(clientRPC, staticAddressResolver(addr)),
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
streamID := execinfrapb.StreamID(42)
var outbox *Outbox
var wg sync.WaitGroup
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// We could test this on ctx.cancel(), but this mock
// cancellation method is simpler.
ctxCanceled := false
mockCancel := func() {
ctxCanceled = true
}
outbox = NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
outbox.Init(rowenc.OneIntCol)
outbox.Start(ctx, &wg, mockCancel)
// Wait for the outbox to connect the stream.
streamNotification := <-mockServer.InboundStreams
if _, err := streamNotification.Stream.Recv(); err != nil {
t.Fatal(err)
}
streamNotification.Donec <- cancelchecker.QueryCanceledError
wg.Wait()
if !ctxCanceled {
t.Fatal("flow ctx was not canceled")
}
}
// Test that the outbox unblocks its producers if it fails to connect during
// startup.
func TestOutboxUnblocksProducers(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
ctx := context.Background()
defer stopper.Stop(ctx)
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(ctx)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
// a nil nodeDialer will always fail to connect.
NodeDialer: nil,
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
streamID := execinfrapb.StreamID(42)
var outbox *Outbox
var wg sync.WaitGroup
ctx, cancel := context.WithCancel(ctx)
defer cancel()
outbox = NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
outbox.Init(rowenc.OneIntCol)
// Fill up the outbox.
for i := 0; i < outboxBufRows; i++ {
outbox.Push(nil, &execinfrapb.ProducerMetadata{})
}
var blockedPusherWg sync.WaitGroup
blockedPusherWg.Add(1)
go func() {
// Push to the outbox one last time, which will block since the channel
// is full.
outbox.Push(nil, &execinfrapb.ProducerMetadata{})
// We should become unblocked once outbox.Start fails.
blockedPusherWg.Done()
}()
// This outbox will fail to connect, because it has a nil nodeDialer.
outbox.Start(ctx, &wg, cancel)
wg.Wait()
// Also, make sure that pushing to the outbox after its failed shows that
// it's been correctly ConsumerClosed.
status := outbox.Push(nil, &execinfrapb.ProducerMetadata{})
if status != execinfra.ConsumerClosed {
t.Fatalf("expected status=ConsumerClosed, got %s", status)
}
blockedPusherWg.Wait()
}
func BenchmarkOutbox(b *testing.B) {
defer leaktest.AfterTest(b)()
// Create a mock server that the outbox will connect and push rows to.
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
clusterID, mockServer, addr, err := execinfrapb.StartMockDistSQLServer(clock, stopper, execinfra.StaticNodeID)
if err != nil {
b.Fatal(err)
}
st := cluster.MakeTestingClusterSettings()
for _, numCols := range []int{1, 2, 4, 8} {
row := rowenc.EncDatumRow{}
for i := 0; i < numCols; i++ {
row = append(row, rowenc.DatumToEncDatum(types.Int, tree.NewDInt(tree.DInt(2))))
}
b.Run(fmt.Sprintf("numCols=%d", numCols), func(b *testing.B) {
streamID := execinfrapb.StreamID(42)
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(context.Background())
clientRPC := rpc.NewInsecureTestingContextWithClusterID(clock, stopper, clusterID)
flowCtx := execinfra.FlowCtx{
EvalCtx: &evalCtx,
ID: execinfrapb.FlowID{UUID: uuid.MakeV4()},
Cfg: &execinfra.ServerConfig{
Settings: st,
Stopper: stopper,
NodeDialer: nodedialer.New(clientRPC, staticAddressResolver(addr)),
},
NodeID: base.NewSQLIDContainer(1, nil /* nodeID */),
}
outbox := NewOutbox(&flowCtx, execinfra.StaticNodeID, streamID, nil /* numOutboxes */, false /* isGatewayNode */)
outbox.Init(rowenc.MakeIntCols(numCols))
var outboxWG sync.WaitGroup
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Start the outbox. This should cause the stream to connect, even though
// we're not sending any rows.
outbox.Start(ctx, &outboxWG, cancel)
// Wait for the outbox to connect the stream.
streamNotification := <-mockServer.InboundStreams
serverStream := streamNotification.Stream
go func() {
for {
_, err := serverStream.Recv()
if err != nil {
break
}
}
}()
b.SetBytes(int64(numCols * 8))
for i := 0; i < b.N; i++ {
if err := outbox.addRow(ctx, row, nil); err != nil {
b.Fatal(err)
}
}
outbox.ProducerDone()
outboxWG.Wait()
streamNotification.Donec <- nil
})
}
}