Skip to content

Commit 5fbdc15

Browse files
authored
fix: remove row count check, replace with threshold (#3756)
1 parent f0120d4 commit 5fbdc15

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cmd/hatchet-migrate/migrate/migrations/20260424190713_v1_0_99.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
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

Comments
 (0)