@@ -25,6 +25,7 @@ import (
2525 "go.opentelemetry.io/otel/trace"
2626 "go.temporal.io/sdk/log"
2727
28+ "github.com/PeerDB-io/peerdb/flow/alerting"
2829 connmetadata "github.com/PeerDB-io/peerdb/flow/connectors/external_metadata"
2930 "github.com/PeerDB-io/peerdb/flow/connectors/utils"
3031 "github.com/PeerDB-io/peerdb/flow/connectors/utils/monitoring"
@@ -59,6 +60,7 @@ type PostgresCDCSource struct {
5960
6061 // for storing schema delta audit logs to catalog
6162 catalogPool shared.CatalogPool
63+ alerter * alerting.Alerter
6264 otelManager * otel_metrics.OtelManager
6365 hushWarnUnhandledMessageType map [pglogrepl.MessageType ]struct {}
6466 hushWarnUnknownTableDetected map [uint32 ]struct {}
@@ -130,6 +132,7 @@ func (c *PostgresConnector) NewPostgresCDCSource(ctx context.Context, cdcConfig
130132 idToRelKindMap : idToRelKindMap ,
131133 publishViaPartitionRoot : publishViaPartitionRoot ,
132134 catalogPool : cdcConfig .CatalogPool ,
135+ alerter : alerting .NewAlerter (ctx , cdcConfig .CatalogPool , cdcConfig .OtelManager ),
133136 otelManager : cdcConfig .OtelManager ,
134137 hushWarnUnhandledMessageType : make (map [pglogrepl.MessageType ]struct {}),
135138 hushWarnUnknownTableDetected : make (map [uint32 ]struct {}),
@@ -584,6 +587,7 @@ func PullCdcRecords[Items model.Items](
584587 defer shutdown ()
585588
586589 var standByLastLogged time.Time
590+ var largeTxnLastLogged time.Time
587591 nextRecordDeadline := time .Now ().Add (req .IdleTimeout )
588592 pkmRequiresResponse := false
589593
@@ -679,11 +683,24 @@ func PullCdcRecords[Items model.Items](
679683 slog .Float64 ("elapsedMinutes" , time .Since (pullStart ).Minutes ()))
680684 return nil
681685 } else {
686+ accumulatedBytes := totalFetchedBytes .Load ()
682687 logger .Info ("commit lock, waiting for commit to return records" ,
683688 slog .Int64 ("records" , totalRecords ),
684- slog .Int64 ("bytes" , totalFetchedBytes . Load () ),
689+ slog .Int64 ("bytes" , accumulatedBytes ),
685690 slog .Int ("channelLen" , records .ChannelLen ()),
686691 slog .Float64 ("elapsedMinutes" , time .Since (pullStart ).Minutes ()))
692+
693+ if time .Since (largeTxnLastLogged ) > time .Minute {
694+ if ! largeTxnLastLogged .IsZero () {
695+ userMsg := fmt .Sprintf (
696+ "Reading a large already-committed transaction off the replication slot; " +
697+ "sync will continue once it's fully received (%d records, %s buffered so far)." ,
698+ totalRecords , utils .HumanReadableBytes (accumulatedBytes ))
699+ p .alerter .LogFlowInfo (ctx , p .flowJobName , userMsg )
700+ }
701+ largeTxnLastLogged = time .Now ()
702+ }
703+
687704 waitingForCommit = true
688705 }
689706 } else {
0 commit comments