From 61de0980721838f1bfe1e335ac3ebe272ca0deaf Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 31 Mar 2020 16:25:16 -0400 Subject: [PATCH 1/2] 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 From 90ad7a061f9ace1fcd752ed42851a0017081268f Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 21 Apr 2020 12:50:23 -0400 Subject: [PATCH 2/2] Handle the rest of `rows.Err` cases --- go/logic/applier.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/logic/applier.go b/go/logic/applier.go index 1bffd7a..783c190 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -371,6 +371,8 @@ func (this *Applier) ReadMigrationMinValues(uniqueKey *sql.UniqueKey) error { } } log.Infof("Migration min values: [%s]", this.migrationContext.MigrationRangeMinValues) + + err = rows.Err() return err } @@ -392,6 +394,8 @@ func (this *Applier) ReadMigrationMaxValues(uniqueKey *sql.UniqueKey) error { } } log.Infof("Migration max values: [%s]", this.migrationContext.MigrationRangeMaxValues) + + err = rows.Err() return err }