Skip to content

Commit

Permalink
move peer fetching inside 10 minute wait cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Nov 27, 2023
1 parent a4407d6 commit 143c961
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions flow/activities/flowable.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,23 +706,22 @@ func (a *FlowableActivity) SendWALHeartbeat(ctx context.Context) error {
sendTimeout := 10 * time.Minute
ticker := time.NewTicker(sendTimeout)
defer ticker.Stop()

pgPeers, err := getPostgresPeerConfigs(ctx)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
log.Warn("[sendwalheartbeat]: warning: peers table not found. Exiting")
return nil
}
return fmt.Errorf("error getting postgres peers: %w", err)
}

activity.RecordHeartbeat(ctx, "sending walheartbeat every 10 minutes")
for {
select {
case <-ctx.Done():
log.Info("context is done, exiting wal heartbeat send loop")
return nil
case <-ticker.C:
pgPeers, err := getPostgresPeerConfigs(ctx)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
log.Warn("[sendwalheartbeat]: warning: peers table not found. Exiting")
return nil
}
return fmt.Errorf("error getting postgres peers: %w", err)
}

command := `
BEGIN;
DROP aggregate IF EXISTS PEERDB_EPHEMERAL_HEARTBEAT(float4);
Expand Down

0 comments on commit 143c961

Please sign in to comment.