Skip to content

Commit

Permalink
Nits: auto-close on failure, and call Close in Stop
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Sep 23, 2024
1 parent 061b56b commit c07556c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/replicator/pgreplicator/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions pkg/replicator/pgreplicator/pgsetup/pgsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c07556c

Please sign in to comment.