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 }