Skip to content

Commit

Permalink
[management] Enforce max conn of 1 for sqlite setups (netbirdio#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer authored Nov 7, 2024
1 parent 6829a64 commit 7fef8f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion management/server/sql_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine StoreEngine, metr
if err != nil {
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)

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 {
return nil, fmt.Errorf("migrate: %w", err)
Expand Down

0 comments on commit 7fef8f6

Please sign in to comment.