~emersion/soju

8849669d61a4c947f802cd84718ab516657c7aa2 — Simon Ser 4 months ago d086872
database/postgres: set max open conns

Open at most 25 connections. Should fix errors such as
"pq: sorry, too many clients already".
1 files changed, 4 insertions(+), 0 deletions(-)

M database/postgres.go
M database/postgres.go => database/postgres.go +4 -0
@@ 175,6 175,10 @@ func OpenPostgresDB(source string) (Database, error) {
		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}
	if err := db.upgrade(); err != nil {
		sqlPostgresDB.Close()