[management] Enforce max conn of 1 for sqlite setups (#2855)

This commit is contained in:
Pascal Fischer 2024-11-07 16:32:35 +01:00 committed by GitHub
parent 6829a64a2d
commit 7fef8f6758
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,9 +69,17 @@ func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine StoreEngine, metr
if err != nil { if err != nil {
conns = runtime.NumCPU() conns = runtime.NumCPU()
} }
if storeEngine == SqliteStoreEngine {
if err == nil {
log.WithContext(ctx).Warnf("setting NB_SQL_MAX_OPEN_CONNS is not supported for sqlite, using default value 1")
}
conns = 1
}
sql.SetMaxOpenConns(conns) sql.SetMaxOpenConns(conns)
log.Infof("Set max open db connections to %d", conns) log.WithContext(ctx).Infof("Set max open db connections to %d", conns)
if err := migrate(ctx, db); err != nil { if err := migrate(ctx, db); err != nil {
return nil, fmt.Errorf("migrate: %w", err) return nil, fmt.Errorf("migrate: %w", err)