You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On my local environment, pollingInterval is set to 5.
Expected Behavior
No connection leaks
Actual Behavior
KEDA opens a connection each 5 seconds and does not close it
# SELECT COUNT(*), state, query FROM pg_stat_activity GROUP BY state, query;
count | state | query
-------+--------+----------------------------------------------------------------------------
1 | active | SELECT COUNT(*), state, query FROM pg_stat_activity GROUP BY state, query;
78 | idle | SELECT COUNT(*)::decimal FROM jobs WHERE state='queued'
5 | |
(3 rows)
Steps to Reproduce the Problem
Setup a postgresql database
Setup a ScaledJob (may use the example from above)
Wait until connection limit is reached
Logs from KEDA operator
22-12-13T17:28:56Z INFO scaleexecutor Scaling Jobs {"scaledJob.Name": "ai-studio", "scaledJob.Namespace": "ai-studio-demo", "Number of running Jobs": 0}
2022-12-13T17:28:56Z INFO scaleexecutor Scaling Jobs {"scaledJob.Name": "ai-studio", "scaledJob.Namespace": "ai-studio-demo", "Number of pending Jobs ": 0}
2022-12-13T17:29:01Z ERROR postgresql_scaler Found error pinging postgreSQL: pq: remaining connection slots are reserved for non-replication superuser connections {"type": "ScaledJob", "namespace": "ai-studio-demo", "name": "ai-studio", "error": "pq: remaining connection slots are reserved for non-replication superuser connections"}
github.com/kedacore/keda/v2/pkg/scalers.getConnection
/workspace/pkg/scalers/postgresql_scaler.go:154
github.com/kedacore/keda/v2/pkg/scalers.NewPostgreSQLScaler
/workspace/pkg/scalers/postgresql_scaler.go:48
github.com/kedacore/keda/v2/pkg/scaling.buildScaler
/workspace/pkg/scaling/scale_handler.go:656
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers.func1
/workspace/pkg/scaling/scale_handler.go:532
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers
/workspace/pkg/scaling/scale_handler.go:536
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).performGetScalersCache
/workspace/pkg/scaling/scale_handler.go:266
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).GetScalersCache
/workspace/pkg/scaling/scale_handler.go:190
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).checkScalers
/workspace/pkg/scaling/scale_handler.go:341
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).startScaleLoop
/workspace/pkg/scaling/scale_handler.go:162
it seems like a regression in 2.9.0. 2.8.1 does not have this issue
postgres=# SELECT COUNT(*), state, query FROM pg_stat_activity GROUP BY state, query;
count | state | query
-------+--------+----------------------------------------------------------------------------
1 | active | SELECT COUNT(*), state, query FROM pg_stat_activity GROUP BY state, query;
1 | idle | SELECT COUNT(*)::decimal FROM jobs WHERE state='queued'
5 | |
(3 rows)
zroubalik
changed the title
connections leak in postgresql scaler with scaledJob
Connections leak in scalers defined in ScaledJob
Dec 14, 2022
Report
I used a ScaledJob with an postgresql to scale job based on tables entries inside postgresql
On my local environment, pollingInterval is set to 5.
Expected Behavior
No connection leaks
Actual Behavior
KEDA opens a connection each 5 seconds and does not close it
Steps to Reproduce the Problem
Logs from KEDA operator
KEDA Version
2.9.0
Kubernetes Version
1.25
Platform
Other
Scaler Details
Postgresql
Anything else?
Slack: https://kubernetes.slack.com/archives/CKZJ36A5D/p1670952481987269
The text was updated successfully, but these errors were encountered: