sqlite: DB connection is not thread safe. Set max open connections to 1
Some checks failed
/ push (push) Has been cancelled
Some checks failed
/ push (push) Has been cancelled
This commit is contained in:
parent
f78661aa6e
commit
327c8380af
3
db/db.go
3
db/db.go
|
@ -38,6 +38,9 @@ func Open(cfg *config.Config) (*sql.DB, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return db, errs.Wrapw(err, "failed to open database", "driver", driver, "db.string", dsn)
|
return db, errs.Wrapw(err, "failed to open database", "driver", driver, "db.string", dsn)
|
||||||
}
|
}
|
||||||
|
if driver == "sqlite3" {
|
||||||
|
db.SetMaxOpenConns(1) // SQLITE is not thread safe. This is to prevent database is locked error.
|
||||||
|
}
|
||||||
if cfg.Bool("db.automigrate") {
|
if cfg.Bool("db.automigrate") {
|
||||||
goose.SetLogger(goose.NopLogger())
|
goose.SetLogger(goose.NopLogger())
|
||||||
goose.SetBaseFS(Migrations)
|
goose.SetBaseFS(Migrations)
|
||||||
|
|
Loading…
Reference in a new issue