Skip to content

Commit 85c6cfc

Browse files
author
James Cor
committed
try rebalancing send/receive threads
1 parent 1a2ee2a commit 85c6cfc

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

server/handler.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
635635

636636
// Read rows off the row iterator and send them to the row channel.
637637
iter, projs := GetDeferredProjections(iter)
638-
var rowChan = make(chan sql.Row, 512)
638+
var rowChan = make(chan []sqltypes.Value, 512)
639639
eg.Go(func() (err error) {
640640
defer pan2err(&err)
641641
defer wg.Done()
@@ -652,8 +652,22 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
652652
if err != nil {
653653
return err
654654
}
655+
656+
if types.IsOkResult(row) {
657+
if len(r.Rows) > 0 {
658+
panic("Got OkResult mixed with RowResult")
659+
}
660+
r = resultFromOkResult(row[0].(types.OkResult))
661+
continue
662+
}
663+
664+
outputRow, err := RowToSQL(ctx, schema, row, projs, buf)
665+
if err != nil {
666+
return err
667+
}
668+
655669
select {
656-
case rowChan <- row:
670+
case rowChan <- outputRow:
657671
case <-ctx.Done():
658672
return nil
659673
}
@@ -718,21 +732,9 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
718732
if !ok {
719733
return nil
720734
}
721-
if types.IsOkResult(row) {
722-
if len(r.Rows) > 0 {
723-
panic("Got OkResult mixed with RowResult")
724-
}
725-
r = resultFromOkResult(row[0].(types.OkResult))
726-
continue
727-
}
728-
729-
outputRow, err := RowToSQL(ctx, schema, row, projs, buf)
730-
if err != nil {
731-
return err
732-
}
733735

734-
ctx.GetLogger().Tracef("spooling result row %s", outputRow)
735-
r.Rows = append(r.Rows, outputRow)
736+
ctx.GetLogger().Tracef("spooling result row %s", row)
737+
r.Rows = append(r.Rows, row)
736738
r.RowsAffected++
737739
if !timer.Stop() {
738740
<-timer.C

0 commit comments

Comments
 (0)