mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
fix(sqlite): stop prepared statements starving the connection pool
This commit is contained in:
@@ -64,7 +64,11 @@ func NewV2(cfg Config) (*GORMStoreV2, error) {
|
|||||||
db, err := gorm.Open(dialector, &gorm.Config{
|
db, err := gorm.Open(dialector, &gorm.Config{
|
||||||
Logger: gormLogger,
|
Logger: gormLogger,
|
||||||
SkipDefaultTransaction: true, // Better performance
|
SkipDefaultTransaction: true, // Better performance
|
||||||
PrepareStmt: true, // Cached prepared statements
|
// A cached statement prepared inside a transaction takes a second pool
|
||||||
|
// connection. With SQLite's single writer, transactions queue on the
|
||||||
|
// write lock holding connections, so the holder can starve for one
|
||||||
|
// and stall until busy_timeout. SQLite prepares cheaply; skip the cache.
|
||||||
|
PrepareStmt: cfg.Driver != "sqlite",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, errors.ErrCodeStorageFailure, "failed to connect to database")
|
return nil, errors.Wrap(err, errors.ErrCodeStorageFailure, "failed to connect to database")
|
||||||
|
|||||||
Reference in New Issue
Block a user