From 23a3ec6954ad2043273397dcfd09c6f4e3abd7ad Mon Sep 17 00:00:00 2001 From: Yasin Zaehringer Date: Tue, 7 May 2024 14:36:30 +0200 Subject: [PATCH] qrep: if the last sync is nil, check the table if there are new rows. (#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. --- flow/activities/flowable.go | 2 +- flow/connectors/postgres/qrep.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flow/activities/flowable.go b/flow/activities/flowable.go index 2291400b03..7571c74b55 100644 --- a/flow/activities/flowable.go +++ b/flow/activities/flowable.go @@ -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 } diff --git a/flow/connectors/postgres/qrep.go b/flow/connectors/postgres/qrep.go index 8ec936d2ea..0d298a193f 100644 --- a/flow/connectors/postgres/qrep.go +++ b/flow/connectors/postgres/qrep.go @@ -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 {