From 846b56d3936679d22dd489936b55bdaa60cf1372 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sun, 11 Dec 2022 17:32:56 +0200 Subject: [PATCH] updated connection pool limits --- core/db_cgo.go | 8 ++++---- core/db_nocgo.go | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/db_cgo.go b/core/db_cgo.go index 9d6cd9360..61b1bd9e4 100644 --- a/core/db_cgo.go +++ b/core/db_cgo.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/pocketbase/dbx" _ "github.com/mattn/go-sqlite3" + "github.com/pocketbase/dbx" ) func connectDB(dbPath string) (*dbx.DB, error) { @@ -24,9 +24,9 @@ func connectDB(dbPath string) (*dbx.DB, error) { // use a fixed connection pool to limit the SQLITE_BUSY errors // and reduce the open file descriptors // (the limits are arbitrary and may change in the future) - db.DB().SetMaxOpenConns(800) - db.DB().SetMaxIdleConns(30) - db.DB().SetConnMaxIdleTime(5 * time.Minute) + db.DB().SetMaxOpenConns(20) + db.DB().SetMaxIdleConns(20) + db.DB().SetConnMaxIdleTime(3 * time.Minute) // additional pragmas not supported through the dsn string _, err := db.NewQuery(` diff --git a/core/db_nocgo.go b/core/db_nocgo.go index 4d4fa64e3..6b5943613 100644 --- a/core/db_nocgo.go +++ b/core/db_nocgo.go @@ -24,11 +24,9 @@ func connectDB(dbPath string) (*dbx.DB, error) { // use a fixed connection pool to limit the SQLITE_BUSY errors and // reduce the open file descriptors // (the limits are arbitrary and may change in the future) - // - // @see https://gitlab.com/cznic/sqlite/-/issues/115 - db.DB().SetMaxOpenConns(800) - db.DB().SetMaxIdleConns(30) - db.DB().SetConnMaxIdleTime(5 * time.Minute) + db.DB().SetMaxOpenConns(20) + db.DB().SetMaxIdleConns(20) + db.DB().SetConnMaxIdleTime(3 * time.Minute) return db, nil }