From 4d4f649edaa77696af647c469b3d3902737dacc4 Mon Sep 17 00:00:00 2001 From: Silvan Date: Thu, 19 Oct 2023 15:37:22 +0200 Subject: [PATCH] fix(db): allow unlimited connections (#6758) --- internal/database/dialect/connections.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/database/dialect/connections.go b/internal/database/dialect/connections.go index bf3a4680f3..cd6e87daa8 100644 --- a/internal/database/dialect/connections.go +++ b/internal/database/dialect/connections.go @@ -16,7 +16,7 @@ func NewConnectionInfo(openConns, idleConns uint32, pusherRatio float64) (*Conne if pusherRatio < 0 || pusherRatio > 1 { return nil, errors.New("EventPushConnRatio must be between 0 and 1") } - if openConns < 2 { + if openConns != 0 && openConns < 2 { return nil, errors.New("MaxOpenConns of the database must be higher that 1") } @@ -25,15 +25,19 @@ func NewConnectionInfo(openConns, idleConns uint32, pusherRatio float64) (*Conne info.EventstorePusher.MaxOpenConns = uint32(pusherRatio * float64(openConns)) info.EventstorePusher.MaxIdleConns = uint32(pusherRatio * float64(idleConns)) - if info.EventstorePusher.MaxOpenConns < 1 && pusherRatio > 0 { + if openConns != 0 && info.EventstorePusher.MaxOpenConns < 1 && pusherRatio > 0 { info.EventstorePusher.MaxOpenConns = 1 } - if info.EventstorePusher.MaxIdleConns < 1 && pusherRatio > 0 { + if idleConns != 0 && info.EventstorePusher.MaxIdleConns < 1 && pusherRatio > 0 { info.EventstorePusher.MaxIdleConns = 1 } - info.ZITADEL.MaxOpenConns = openConns - info.EventstorePusher.MaxOpenConns - info.ZITADEL.MaxIdleConns = idleConns - info.EventstorePusher.MaxIdleConns + if openConns != 0 { + info.ZITADEL.MaxOpenConns = openConns - info.EventstorePusher.MaxOpenConns + } + if idleConns != 0 { + info.ZITADEL.MaxIdleConns = idleConns - info.EventstorePusher.MaxIdleConns + } return info, nil }