Skip to content

Commit

Permalink
SF merge: don't return gCtx.Err, defer to g.Wait (#1464)
Browse files Browse the repository at this point in the history
Returning `gCtx.Err()` caused errors to be logged only as "context canceled"

Still need to check `ctx.Err()` to avoid returning nil with partial merge
  • Loading branch information
serprex authored Mar 11, 2024
1 parent 2bf9ac4 commit a233c63
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flow/connectors/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ func (c *SnowflakeConnector) mergeTablesForBatch(
g.SetLimit(8) // limit parallel merges to 8

for _, tableName := range destinationTableNames {
if err := gCtx.Err(); err != nil {
return fmt.Errorf("canceled while normalizing records: %w", err)
if gCtx.Err() != nil {
break
}

g.Go(func() error {
Expand Down Expand Up @@ -597,6 +597,9 @@ func (c *SnowflakeConnector) mergeTablesForBatch(
if err := g.Wait(); err != nil {
return fmt.Errorf("error while normalizing records: %w", err)
}
if err := ctx.Err(); err != nil {
return fmt.Errorf("normalize canceled: %w", err)
}

return nil
}
Expand Down

0 comments on commit a233c63

Please sign in to comment.