44 "context"
55 "database/sql"
66 "fmt"
7+ "math"
78 "strings"
89
910 "github.com/pressly/goose/v3"
@@ -578,7 +579,6 @@ func up20260424190713(ctx context.Context, db *sql.DB) error {
578579 {v1TasksOlapTable , v1TasksOlapTable + "_new" },
579580 {v1DagsOlapTable , v1DagsOlapTable + "_new" },
580581 } {
581- var countsMatch bool
582582 var newCount , existingCount int64
583583
584584 if err := db .QueryRowContext (ctx , fmt .Sprintf (`
@@ -587,13 +587,13 @@ func up20260424190713(ctx context.Context, db *sql.DB) error {
587587 (SELECT COUNT(*) FROM %s) AS new_count,
588588 (SELECT COUNT(*) FROM %s) AS existing_count
589589 )
590- SELECT new_count = existing_count, new_count , existing_count
590+ SELECT new_count, existing_count
591591 FROM counts
592- ` , table .dst , table .src )).Scan (& countsMatch , & newCount , & existingCount ); err != nil {
592+ ` , table .dst , table .src )).Scan (& newCount , & existingCount ); err != nil {
593593 return fmt .Errorf ("counting rows in %s and %s: %w" , table .dst , table .src , err )
594594 }
595595
596- if ! countsMatch {
596+ if math . Abs ( float64 ( newCount ) - float64 ( existingCount )) > 1000 {
597597 return fmt .Errorf ("row count mismatch after backfill for %s: new=%d, existing=%d" , table .src , newCount , existingCount )
598598 }
599599 }
0 commit comments