Manager: limit database connections
Limit the database connection pool to only a single connection. I hope that this will solve the intermittent `SQLITE_BUSY` errors I've been seeing.
This commit is contained in:
parent
4bdaeb73a6
commit
d35ca9d98f
@ -62,6 +62,16 @@ func openDBWithConfig(dsn string, config *gorm.Config) (*DB, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Use the generic sql.DB interface to set some connection pool options.
|
||||
sqlDB, err := gormDB.DB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Only allow a single database connection, to avoid SQLITE_BUSY errors.
|
||||
// It's not certain that this'll improve the situation, but it's worth a try.
|
||||
sqlDB.SetMaxIdleConns(1) // Max num of connections in the idle connection pool.
|
||||
sqlDB.SetMaxOpenConns(1) // Max num of open connections to the database.
|
||||
|
||||
db := DB{
|
||||
gormDB: gormDB,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user