Skip to content

Commit

Permalink
qrep: if the last sync is nil, check the table if there are new rows. (
Browse files Browse the repository at this point in the history
…#1667)

this bug can prevent tables which are empty to be synced once they get
data.

in general one has to be very careful here with nil pointer exceptions,
I tried to navigate them to the best of my ability but this code path
makes lots of assumptions about the state of the world.
  • Loading branch information
yasinzaehringer-paradime authored May 7, 2024
1 parent e8ebd3c commit 23a3ec6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flow/activities/flowable.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func (a *FlowableActivity) QRepHasNewRows(ctx context.Context,
ctx = context.WithValue(ctx, shared.FlowNameKey, config.FlowJobName)
logger := log.With(activity.GetLogger(ctx), slog.String(string(shared.FlowNameKey), config.FlowJobName))

if config.SourcePeer.Type != protos.DBType_POSTGRES || last.Range == nil {
if config.SourcePeer.Type != protos.DBType_POSTGRES {
return QRepWaitUntilNewRowsResult{Found: true}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions flow/connectors/postgres/qrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ func (c *PostgresConnector) CheckForUpdatedMaxValue(
return false, fmt.Errorf("error while getting min and max values: %w", err)
}

if last == nil || last.Range == nil {
return maxValue != nil, nil
}

switch x := last.Range.Range.(type) {
case *protos.PartitionRange_IntRange:
if maxValue.(int64) > x.IntRange.End {
Expand Down

0 comments on commit 23a3ec6

Please sign in to comment.