mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-11-28 18:11:17 +02:00
updated db pool limits
This commit is contained in:
parent
8bb03d2e6b
commit
1a28532546
@ -4,6 +4,7 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
@ -20,6 +21,13 @@ func connectDB(dbPath string) (*dbx.DB, error) {
|
|||||||
return nil, openErr
|
return nil, openErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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(500)
|
||||||
|
db.DB().SetMaxIdleConns(30)
|
||||||
|
db.DB().SetConnMaxIdleTime(5 * time.Minute)
|
||||||
|
|
||||||
// additional pragmas not supported through the dsn string
|
// additional pragmas not supported through the dsn string
|
||||||
_, err := db.NewQuery(`
|
_, err := db.NewQuery(`
|
||||||
pragma journal_size_limit = 100000000;
|
pragma journal_size_limit = 100000000;
|
||||||
|
@ -14,18 +14,20 @@ func connectDB(dbPath string) (*dbx.DB, error) {
|
|||||||
// note: the busy_timeout pragma must be first because
|
// note: the busy_timeout pragma must be first because
|
||||||
// the connection needs to be set to block on busy before WAL mode
|
// the connection needs to be set to block on busy before WAL mode
|
||||||
// is set in case it hasn't been already set by another connection
|
// is set in case it hasn't been already set by another connection
|
||||||
pragmas := "_pragma=busy_timeout(100000)&_pragma=journal_mode(WAL)&_pragma=foreign_keys(1)&_pragma=synchronous(NORMAL)&_pragma=journal_size_limit(100000000)"
|
pragmas := "_pragma=busy_timeout(10000)&_pragma=journal_mode(WAL)&_pragma=foreign_keys(1)&_pragma=synchronous(NORMAL)&_pragma=journal_size_limit(100000000)"
|
||||||
|
|
||||||
db, err := dbx.MustOpen("sqlite", fmt.Sprintf("%s?%s", dbPath, pragmas))
|
db, err := dbx.MustOpen("sqlite", fmt.Sprintf("%s?%s", dbPath, pragmas))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
// (the limits are arbitrary and may change in the future)
|
||||||
//
|
//
|
||||||
// @see https://gitlab.com/cznic/sqlite/-/issues/115
|
// @see https://gitlab.com/cznic/sqlite/-/issues/115
|
||||||
db.DB().SetMaxOpenConns(200)
|
db.DB().SetMaxOpenConns(500)
|
||||||
db.DB().SetMaxIdleConns(200)
|
db.DB().SetMaxIdleConns(30)
|
||||||
db.DB().SetConnMaxIdleTime(5 * time.Minute)
|
db.DB().SetConnMaxIdleTime(5 * time.Minute)
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user