From c07556c3448b2fc43aebc27a29fdf76faacf00ff Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown Date: Mon, 23 Sep 2024 20:12:14 +0000 Subject: [PATCH] Nits: auto-close on failure, and call Close in Stop --- pkg/replicator/pgreplicator/pg.go | 2 ++ pkg/replicator/pgreplicator/pgsetup/pgsetup.go | 1 + 2 files changed, 3 insertions(+) diff --git a/pkg/replicator/pgreplicator/pg.go b/pkg/replicator/pgreplicator/pg.go index d115f6e..7f0041d 100644 --- a/pkg/replicator/pgreplicator/pg.go +++ b/pkg/replicator/pgreplicator/pg.go @@ -128,6 +128,7 @@ type pg struct { func (p *pg) Stop() { atomic.StoreInt32(&p.stopped, 1) + _ = p.Close(context.Background()) } func (p *pg) Close(ctx context.Context) error { @@ -180,6 +181,7 @@ func (p *pg) Connect(ctx context.Context, lsn pglogrepl.LSN) error { }, ) if err != nil { + _ = p.Close(ctx) if converted, newErr := standardizeErr(err); converted { return newErr } diff --git a/pkg/replicator/pgreplicator/pgsetup/pgsetup.go b/pkg/replicator/pgreplicator/pgsetup/pgsetup.go index ed2c563..965c228 100644 --- a/pkg/replicator/pgreplicator/pgsetup/pgsetup.go +++ b/pkg/replicator/pgreplicator/pgsetup/pgsetup.go @@ -199,6 +199,7 @@ func (s *setup) createUser(ctx context.Context) error { return s.res.UserCreated.Error } s.res.UserCreated.Error = nil + s.res.UserCreated.Complete = true return nil }