mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-18 07:30:29 +00:00
perf(pglite): keep pooled connections idle instead of churning them
database/sql keeps only 2 idle connections by default, so with 4 open the pool closed and reopened connections constantly: about 225 Terminate+handshake cycles per minute during a scan on roy. Every handshake goes through the single backend, and the first query after a handshake is where the lost replies were seen.
This commit is contained in:
parent
0cf80707ac
commit
a21c4c92fc
3
db/db.go
3
db/db.go
@ -55,7 +55,10 @@ func Db() *sql.DB {
|
||||
log.Fatal("Error opening database", err)
|
||||
}
|
||||
// One PGlite backend means one PG session; the bridge serializes clients onto it.
|
||||
// Keep every connection idle rather than churning handshakes through the backend.
|
||||
db.SetMaxOpenConns(4)
|
||||
db.SetMaxIdleConns(4)
|
||||
db.SetConnMaxLifetime(0)
|
||||
abs, _ := filepath.Abs(socketDir)
|
||||
log.Info("Embedded PGlite ready", "psql", "PGPASSWORD=x PGSSLMODE=disable psql -h "+abs+" -U postgres navidrome")
|
||||
return db
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user