Skip to content

Commit 0247b64

Browse files
author
James Cor
committed
fix timer again
1 parent 6ef2a9b commit 0247b64

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

server/handler.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ func (h *Handler) doQuery(
499499
r, processedAtLeastOneBatch, err = h.resultForValueRowIter(sqlCtx, c, schema, vr, resultFields, buf, callback, more)
500500
} else {
501501
r, processedAtLeastOneBatch, err = h.resultForDefaultIter(sqlCtx, c, schema, rowIter, callback, resultFields, more, buf)
502+
if err != nil {
503+
return remainder, err
504+
}
502505
}
503506
if err != nil {
504507
return remainder, err
@@ -714,6 +717,13 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
714717
case <-ctx.Done():
715718
return context.Cause(ctx)
716719

720+
case <-timer.C:
721+
if h.readTimeout != 0 {
722+
// Cancel and return so Vitess can call the CloseConnection callback
723+
ctx.GetLogger().Tracef("connection timeout")
724+
return ErrRowTimeout.New()
725+
}
726+
717727
case row, ok := <-rowChan:
718728
if !ok {
719729
return nil
@@ -892,6 +902,13 @@ func (h *Handler) resultForValueRowIter(ctx *sql.Context, c *mysql.Conn, schema
892902
case <-ctx.Done():
893903
return context.Cause(ctx)
894904

905+
case <-timer.C:
906+
if h.readTimeout != 0 {
907+
// Cancel and return so Vitess can call the CloseConnection callback
908+
ctx.GetLogger().Tracef("connection timeout")
909+
return ErrRowTimeout.New()
910+
}
911+
895912
case row, ok := <-rowChan:
896913
if !ok {
897914
return nil
@@ -968,7 +985,7 @@ func (h *Handler) resultForValueRowIter(ctx *sql.Context, c *mysql.Conn, schema
968985
}
969986

970987
res.Rows = res.Rows[:res.RowsAffected]
971-
return res, processedAtLeastOneBatch, nil
988+
return res, processedAtLeastOneBatch, err
972989
}
973990

974991
// See https://dev.mysql.com/doc/internals/en/status-flags.html

0 commit comments

Comments
 (0)