updated connection pool limits
This commit is contained in:
parent
f30c9f263f
commit
846b56d393
|
@ -6,8 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func connectDB(dbPath string) (*dbx.DB, error) {
|
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
|
// use a fixed connection pool to limit the SQLITE_BUSY errors
|
||||||
// and reduce the open file descriptors
|
// and reduce the open file descriptors
|
||||||
// (the limits are arbitrary and may change in the future)
|
// (the limits are arbitrary and may change in the future)
|
||||||
db.DB().SetMaxOpenConns(800)
|
db.DB().SetMaxOpenConns(20)
|
||||||
db.DB().SetMaxIdleConns(30)
|
db.DB().SetMaxIdleConns(20)
|
||||||
db.DB().SetConnMaxIdleTime(5 * time.Minute)
|
db.DB().SetConnMaxIdleTime(3 * time.Minute)
|
||||||
|
|
||||||
// additional pragmas not supported through the dsn string
|
// additional pragmas not supported through the dsn string
|
||||||
_, err := db.NewQuery(`
|
_, err := db.NewQuery(`
|
||||||
|
|
|
@ -24,11 +24,9 @@ func connectDB(dbPath string) (*dbx.DB, error) {
|
||||||
// use a fixed connection pool to limit the SQLITE_BUSY errors and
|
// use a fixed connection pool to limit the SQLITE_BUSY errors and
|
||||||
// reduce the open file descriptors
|
// reduce the open file descriptors
|
||||||
// (the limits are arbitrary and may change in the future)
|
// (the limits are arbitrary and may change in the future)
|
||||||
//
|
db.DB().SetMaxOpenConns(20)
|
||||||
// @see https://gitlab.com/cznic/sqlite/-/issues/115
|
db.DB().SetMaxIdleConns(20)
|
||||||
db.DB().SetMaxOpenConns(800)
|
db.DB().SetConnMaxIdleTime(3 * time.Minute)
|
||||||
db.DB().SetMaxIdleConns(30)
|
|
||||||
db.DB().SetConnMaxIdleTime(5 * time.Minute)
|
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue