From 7fef8f67586e9a2a2b98c1089cb9ccb5e159a81c Mon Sep 17 00:00:00 2001 From: Pascal Fischer <32096965+pascal-fischer@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:32:35 +0100 Subject: [PATCH] [management] Enforce max conn of 1 for sqlite setups (#2855) --- management/server/sql_store.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/management/server/sql_store.go b/management/server/sql_store.go index b1b8330ba..646184578 100644 --- a/management/server/sql_store.go +++ b/management/server/sql_store.go @@ -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)