database/postgres: set max open conns
Open at most 25 connections. Should fix errors such as "pq: sorry, too many clients already".
This commit is contained in:
parent
d0868722cd
commit
8849669d61
@ -175,6 +175,10 @@ func OpenPostgresDB(source string) (Database, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By default sql.DB doesn't have a connection limit. This can cause errors
|
||||||
|
// because PostgreSQL has a default of 100 max connections.
|
||||||
|
sqlPostgresDB.SetMaxOpenConns(25)
|
||||||
|
|
||||||
db := &PostgresDB{db: sqlPostgresDB}
|
db := &PostgresDB{db: sqlPostgresDB}
|
||||||
if err := db.upgrade(); err != nil {
|
if err := db.upgrade(); err != nil {
|
||||||
sqlPostgresDB.Close()
|
sqlPostgresDB.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user