Fixed excessive db conns in middleware and pgx race condition on init
This commit is contained in:
parent
aa6428f3a4
commit
859a78c079
|
@ -45,6 +45,11 @@ type ConnOrTx interface {
|
|||
|
||||
var pgTypeMap = pgtype.NewMap()
|
||||
|
||||
func init() {
|
||||
// NOTE(asaf): Need to initialize it here to avoid potential race conditions later
|
||||
pgTypeMap.TypeForValue(nil)
|
||||
}
|
||||
|
||||
// Creates a new connection to the HMN database.
|
||||
// This connection is not safe for concurrent use.
|
||||
func NewConn() *pgx.Conn {
|
||||
|
|
|
@ -152,7 +152,7 @@ func FetchProjects(
|
|||
}
|
||||
|
||||
// Do the query
|
||||
projectRows, err := db.Query[projectRow](ctx, dbConn, qb.String(), qb.Args()...)
|
||||
projectRows, err := db.Query[projectRow](ctx, tx, qb.String(), qb.Args()...)
|
||||
if err != nil {
|
||||
return nil, oops.New(err, "failed to fetch projects")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue