From 61de0980721838f1bfe1e335ac3ebe272ca0deaf Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 31 Mar 2020 16:25:16 -0400 Subject: [PATCH] Add a check to rows.Err after processing all rows Closes #822. In https://github.com/go-sql-driver/mysql/issues/1075, @acharis notes that the way the go-sql driver is written, query timeout errors don't get set in `rows.Err()` until _after_ a call to `rows.Next()` is made. Because this kind of error means there will be no rows in the result set, the `for rows.Next()` will never enter the for loop, so we must check the value of `rows.Err()` after the loop, and surface the error up appropriately. --- go/logic/applier.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go/logic/applier.go b/go/logic/applier.go index 5fb795b..1bffd7a 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -444,6 +444,9 @@ func (this *Applier) CalculateNextIterationRangeEndValues() (hasFurtherRange boo } hasFurtherRange = true } + if err = rows.Err(); err != nil { + return hasFurtherRange, err + } if hasFurtherRange { this.migrationContext.MigrationIterationRangeMaxValues = iterationRangeMaxValues return hasFurtherRange, nil