Skip to content

Commit

Permalink
Release database connections instead of closing them
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro committed May 7, 2022
1 parent 6a4f7ea commit 639f24e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func applyMigrations(pool *pgx.ConnPool) {
log.Printf("Failed to acquire database connection: %v\n", err)
os.Exit(1)
}
defer conn.Close()
defer pool.Release(conn)

err = db.ApplyMigrations(conn, "./sql")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/jobs/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (j *ReportJob) Execute() {
log.Printf("Failed to acquire database connection: %v\n", err)
return
}
defer readerConn.Close()
defer j.Pool.Release(readerConn)

rows, err := getReadersToNotify(readerConn)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func (j *ReportJob) Execute() {
log.Printf("Failed to acquire database connection: %v\n", err)
return
}
defer reportConn.Close()
defer j.Pool.Release(reportConn)

for rows.Next() {
// Read the next row from the database
Expand Down

0 comments on commit 639f24e

Please sign in to comment.