Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: better default connections (#12669)

Danny Xuf06c7b9d6dfe
diff --git a/backend/component/state/state.go b/backend/component/state/state.go
index 190780061f..6c21fb37d2 100644
--- a/backend/component/state/state.go
+++ b/backend/component/state/state.go
@@ -12,8 +12,8 @@ import (
"github.com/pkg/errors"
)
-// DefaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.
-const DefaultInstanceMaximumConnections = 10
+// defaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.
+const defaultInstanceMaximumConnections = 10
// State is the state for all in-memory states within the server.
type State struct {
@@ -97,6 +97,10 @@ type connectionLimiter struct {
func (c *connectionLimiter) Increment(instanceID, maxConnections int) bool {
c.Lock()
defer c.Unlock()
+ if maxConnections == 0 {
+ maxConnections = defaultInstanceMaximumConnections
+ }
+
if c.connections[instanceID] >= maxConnections {
return true
}
diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.go
index 9cfd466efd..29de03f664 100644
--- a/backend/runner/plancheck/scheduler.go
+++ b/backend/runner/plancheck/scheduler.go
@@ -113,9 +113,6 @@ func (s *Scheduler) runPlanCheckRun(ctx context.Context, planCheckRun *store.Pla
}
maximumConnections := int(instance.Options.GetMaximumConnections())
- if maximumConnections == 0 {
- maximumConnections = state.DefaultInstanceMaximumConnections
- }
if s.stateCfg.InstanceOutstandingConnections.Increment(instanceUID, maximumConnections) {
return
}
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index 3efb648aaf..d1921ec5d6 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -365,9 +365,6 @@ func (s *SchedulerV2) scheduleRunningTaskRuns(ctx context.Context) error {
continue
}
maximumConnections := int(instance.Options.GetMaximumConnections())
- if maximumConnections == 0 {
- maximumConnections = state.DefaultInstanceMaximumConnections
- }
if s.stateCfg.InstanceOutstandingConnections.Increment(task.InstanceID, maximumConnections) {
continue
}