Skip to content

Commit

Permalink
chore: set maxopencons to 1 for sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Jan 31, 2023
1 parent bd84114 commit d8e27e2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/storage/sql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ func Open(cfg config.Config, opts ...Option) (*sql.DB, Driver, error) {

sql.SetMaxIdleConns(cfg.Database.MaxIdleConn)

// if driver == SQLite {
// sql.SetMaxOpenConns(1)
// } else if cfg.Database.MaxOpenConn > 0 {
sql.SetMaxOpenConns(cfg.Database.MaxOpenConn)
// }
if cfg.Database.MaxOpenConn > 0 {
sql.SetMaxOpenConns(cfg.Database.MaxOpenConn)
}

// if we're using sqlite, we need to set always set the max open connections to 1
// see: https:/mattn/go-sqlite3/issues/274
if driver == SQLite {
sql.SetMaxOpenConns(1)
}

if cfg.Database.ConnMaxLifetime > 0 {
sql.SetConnMaxLifetime(cfg.Database.ConnMaxLifetime)
Expand Down

0 comments on commit d8e27e2

Please sign in to comment.