diff --git a/core/services/pg/lease_lock.go b/core/services/pg/lease_lock.go index 58ec2781245..f366c77e5ba 100644 --- a/core/services/pg/lease_lock.go +++ b/core/services/pg/lease_lock.go @@ -8,6 +8,7 @@ import ( "time" "github.com/google/uuid" + "github.com/jackc/pgconn" "github.com/jmoiron/sqlx" "github.com/pkg/errors" "go.uber.org/multierr" @@ -220,6 +221,11 @@ func (l *leaseLock) loop(ctx context.Context) { } cancel() if err != nil { + var pgErr pgconn.PgError + const ReadOnlyTransaction = "25006" + if errors.As(err, &pgErr) && pgErr.Code == ReadOnlyTransaction { + l.logger.Fatal("Read-only connection, exiting immediately") + } l.logger.Errorw("Error trying to refresh database lease", "err", err) } else if !gotLease { if err := l.db.Close(); err != nil {