From 2a1d4d8e8355acb08dee607c80b2a51a943cfe20 Mon Sep 17 00:00:00 2001 From: Wes Date: Fri, 5 Apr 2024 13:55:56 -0700 Subject: [PATCH] fix: postgres db events listener initialization (#1187) The `PullSchema` stream was broken causing issues for things like `ftl dev` which relies on updates to know when and how to rebuild. The `LISTEN` needs to be called on each `topic` we want to listen to so we added a loop to listen to all topic channels. Fixes #1182 --- backend/controller/dal/notify.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/controller/dal/notify.go b/backend/controller/dal/notify.go index c604e99879..10137deecb 100644 --- a/backend/controller/dal/notify.go +++ b/backend/controller/dal/notify.go @@ -57,15 +57,19 @@ func (d *DAL) runListener(ctx context.Context, conn *pgx.Conn) { // Wait for the notification channel to be ready. retry := backoff.Backoff{} - for { - _, err := conn.Exec(ctx, "LISTEN notify_events") - if err == nil { - break + channels := []string{"deployments_events", "topics_events", "topic_events_events"} + for _, channel := range channels { + for { + _, err := conn.Exec(ctx, "LISTEN "+channel) + if err == nil { + logger.Debugf("Listening to channel: %s", channel) + retry.Reset() + break + } + logger.Errorf(err, "Failed to LISTEN to %s", channel) + time.Sleep(retry.Duration()) } - logger.Errorf(err, "failed to LISTEN notify_events") - time.Sleep(retry.Duration()) } - retry.Reset() // Main loop for listening to notifications. for {