@@ -2,7 +2,6 @@ package plugin
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"log"
8
7
"sync"
@@ -55,9 +54,6 @@ type QueryData struct {
55
54
listWg sync.WaitGroup
56
55
// when executing parent child list calls, we cache the parent list result in the query data passed to the child list call
57
56
parentItem interface {}
58
-
59
- // there was an error streaming to the grpc stream
60
- streamingError error
61
57
}
62
58
63
59
func newQueryData (queryContext * QueryContext , table * Table , stream proto.WrapperPlugin_ExecuteServer , connection * Connection , matrix []map [string ]interface {}, connectionManager * connection_manager.Manager ) * QueryData {
@@ -265,9 +261,11 @@ func (d *QueryData) verifyCallerIsListCall(callingFunction string) bool {
265
261
}
266
262
267
263
func (d * QueryData ) streamLeafListItem (ctx context.Context , item interface {}) {
268
- if d .streamingError != nil {
269
- // if there is streaming error, panic to force exit thread - this will be recovered higher up
270
- panic (d .streamingError )
264
+ // if the context is cancelled, panic to break out
265
+ select {
266
+ case <- d .stream .Context ().Done ():
267
+ panic (contextCancelledError )
268
+ default :
271
269
}
272
270
273
271
// create rowData, passing matrixItem from context
@@ -292,8 +290,6 @@ func (d *QueryData) streamRows(_ context.Context, rowChan chan *proto.Row) error
292
290
for {
293
291
// wait for either an item or an error
294
292
select {
295
- case <- d .stream .Context ().Done ():
296
- d .streamingError = errors .New (contextCancelledError )
297
293
case err := <- d .errorChan :
298
294
log .Printf ("[ERROR] streamRows error chan select: %v\n " , err )
299
295
return err
@@ -306,10 +302,6 @@ func (d *QueryData) streamRows(_ context.Context, rowChan chan *proto.Row) error
306
302
return nil
307
303
}
308
304
if err := d .streamRow (row ); err != nil {
309
- // if there was an error streaming, store in d.streamingError
310
- // - this is checked by the thread streaming list items and will cause it to terminate
311
- d .streamingError = err
312
-
313
305
return err
314
306
}
315
307
}
0 commit comments