Skip to content

Commit

Permalink
updated connection pool limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Dec 11, 2022
1 parent f30c9f2 commit 846b56d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions core/db_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(`
Expand Down
8 changes: 3 additions & 5 deletions core/db_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 846b56d

Please sign in to comment.