Skip to content

Commit

Permalink
sundry cdc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Oct 22, 2023
1 parent d5e6d36 commit 1c24d3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion flow/connectors/postgres/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func (p *PostgresCDCSource) consumeStream(
consumedXLogPos = clientXLogPos - 1
}

var standByLastLogged time.Time

for {
if time.Now().After(nextStandbyMessageDeadline) ||
(len(records.Records) >= int(req.MaxBatchSize)) {
Expand All @@ -167,7 +169,12 @@ func (p *PostgresCDCSource) consumeStream(

numRowsProcessedMessage := fmt.Sprintf("processed %d rows", len(records.Records))
utils.RecordHeartbeatWithRecover(p.ctx, numRowsProcessedMessage)
log.Infof("Sent Standby status message. %s", numRowsProcessedMessage)

if time.Since(standByLastLogged) > 10*time.Second {
log.Infof("Sent Standby status message. %s", numRowsProcessedMessage)
standByLastLogged = time.Now()
}

nextStandbyMessageDeadline = time.Now().Add(standbyMessageTimeout)

if !p.commitLock && (len(records.Records) >= int(req.MaxBatchSize)) {
Expand Down
4 changes: 2 additions & 2 deletions flow/workflows/sync_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (s *SyncFlowExecution) executeSyncFlow(
}

startFlowCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
StartToCloseTimeout: 24 * time.Hour,
StartToCloseTimeout: 72 * time.Hour,
// TODO: activity needs to call heartbeat.
// see https://github.com/PeerDB-io/nexus/issues/216
HeartbeatTimeout: 30 * time.Second,
HeartbeatTimeout: 24 * time.Hour,
})

// execute StartFlow on the peers to start the flow
Expand Down

0 comments on commit 1c24d3e

Please sign in to comment.