Skip to content

Commit 28d132e

Browse files
fix(flowable): do not gate pg dest logic by pg source (#4483)
Postgres destination mirrors store metadata on the destination PG peer instead of catalog. We handle this logic for PG to PG mirrors but not MySQL to PG or Mongo to PG. This PR extends this logic to fix CDC for those mirrors too, by only checking if destination is PG regardless of what source is
1 parent 64ab724 commit 28d132e

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

flow/activities/flowable_core.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,16 @@ func pullAndSyncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDC
201201
}
202202

203203
syncBatchID, err := func() (int64, error) {
204-
// special case pg-pg replication, where batch ID is stored on destination instead of catalog
205-
if _, isSourcePg := any(srcConn).(*connpostgres.PostgresConnector); isSourcePg {
206-
dstPgConn, dstPgClose, err := connectors.GetPostgresConnectorByName(ctx, config.Env, a.CatalogPool, config.DestinationName)
207-
if err != nil {
208-
if !errors.Is(err, errors.ErrUnsupported) {
209-
return 0, fmt.Errorf("failed to get destination connector to get last sync batch ID: %w", err)
210-
}
211-
// else fallthrough to loading from catalog
212-
} else {
213-
defer dstPgClose(ctx)
214-
return dstPgConn.GetLastSyncBatchID(ctx, flowName)
204+
// when destination is PG, batch ID is stored on destination instead of catalog
205+
dstPgConn, dstPgClose, err := connectors.GetPostgresConnectorByName(ctx, config.Env, a.CatalogPool, config.DestinationName)
206+
if err != nil {
207+
if !errors.Is(err, errors.ErrUnsupported) {
208+
return 0, fmt.Errorf("failed to get destination connector to get last sync batch ID: %w", err)
215209
}
210+
// else fallthrough to loading from catalog
211+
} else {
212+
defer dstPgClose(ctx)
213+
return dstPgConn.GetLastSyncBatchID(ctx, flowName)
216214
}
217215
pgMetadata := connmetadata.NewPostgresMetadataFromCatalog(logger, a.CatalogPool)
218216
return pgMetadata.GetLastSyncBatchID(ctx, flowName)

0 commit comments

Comments
 (0)