Repository navigation
fix: propagate helm postgres pool variables to db connection - #3032
Merged
Merged
Conversation
…tion Signed-off-by: Joel Copi <joel.copi@solo.io>
Signed-off-by: Joel Copi <joel.copi@solo.io>
EItanya
reviewed
Oct 2, 2026
Signed-off-by: Joel Copi <joel.copi@solo.io>
jcopi
force-pushed
the
jcopi/postgres-idle-connections
branch
from
October 2, 2026 14:55
c12a3e8 to
1d72e8d
Compare
EItanya
approved these changes
Oct 2, 2026
EItanya
enabled auto-merge
October 2, 2026 15:37
moezdil
reviewed
Oct 2, 2026
| db, err := database.Connect(ctx, &database.PostgresConfig{ | ||
| URL: dbURL, | ||
| VectorEnabled: vectorEnabled, | ||
| MaxConns: new(int32(kagentenv.PostgresDatabaseMaxConns.Get())), |
Contributor
There was a problem hiding this comment.
always non-nil here overrides pool_max_conns set in the url
| "KAGENT_POSTGRES_DATABASE_URL_FILE", "", | ||
| "File containing the PostgreSQL connection URL; takes precedence over KAGENT_POSTGRES_DATABASE_URL in the controller.", ComponentDatabase, ComponentController, | ||
| ) | ||
| PostgresDatabaseMaxConns = RegisterIntVar("KAGENT_POSTGRES_DATABASE_MAX_CONNS", max(4, runtime.NumCPU()), "Maximum size of the PostgreSQL connection pool", ComponentDatabase, ComponentController) |
Contributor
There was a problem hiding this comment.
env docs render numcpu, so env-docs-check differs per machine
Signed-off-by: Joel Copi <joel.copi@solo.io>
auto-merge was automatically disabled
October 2, 2026 15:44
Head branch was pushed to by a user without write access
EItanya
approved these changes
Oct 2, 2026
Signed-off-by: Joel Copi <joel.copi@solo.io>
EItanya
approved these changes
Oct 2, 2026
EItanya
added a commit
that referenced
this pull request
Oct 3, 2026
Several controller workers query PostgreSQL every second even when there is no pending work, which keeps serverless databases active. This makes sandbox expiration, scheduled-run reservation and execution, and runtime revision cleanup intervals configurable through the existing environment accessors, preserving current defaults. Workers reject nonpositive intervals. Session quiescence stays fixed at one second because longer intervals leave actors running after task completion or while waiting for input. #3040 tracks waking these workers in memory after settlement, with slower recovery scans. This PR does not eliminate all idle database polling. Agent and sandbox-template preparation checks also stay fixed at one second. They scan cached state and do not query PostgreSQL once preparation and cleanup are settled, so slowing them would delay readiness without helping the database become idle. Forward-ports [dd889a1](dd889a1) to the current MCPServer and RemoteMCPServer controllers: discovery keeps its existing cadence, while unchanged catalogs skip PostgreSQL writes. Failed writes and deletion invalidate the cached observation so retries still reach the database. `LastConnected` records the last persisted connected observation. Uses the PostgreSQL pool configuration from #3032. Defaults and latency tradeoffs stay in the existing environment-variable reference, including the 30-second lateness window for cron firings. Validation: affected Go packages with the race detector, including an MCP test that closes the PostgreSQL pool before repeating unchanged discovery; Go lint; Helm controller/database tests; generated environment documentation check. --------- Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
alexdarbyshire
pushed a commit
to alexdarbyshire/kagent
that referenced
this pull request
Oct 5, 2026
…dev#3032) Use database pool environment variables rendered by the helm chart https://github.com/kagent-dev/kagent/blob/4dce53de7a27ac48fff6b459fbf3b5e507a6d759/helm/kagent/templates/controller-configmap.yaml#L69-L82 in the `database.Connect`. Defaults are pulled from pgx so if no `database.postgres.pool` values are set there should be no behavior change. --------- Signed-off-by: Joel Copi <joel.copi@solo.io>
alexdarbyshire
pushed a commit
to alexdarbyshire/kagent
that referenced
this pull request
Oct 5, 2026
…t-dev#3038) Several controller workers query PostgreSQL every second even when there is no pending work, which keeps serverless databases active. This makes sandbox expiration, scheduled-run reservation and execution, and runtime revision cleanup intervals configurable through the existing environment accessors, preserving current defaults. Workers reject nonpositive intervals. Session quiescence stays fixed at one second because longer intervals leave actors running after task completion or while waiting for input. kagent-dev#3040 tracks waking these workers in memory after settlement, with slower recovery scans. This PR does not eliminate all idle database polling. Agent and sandbox-template preparation checks also stay fixed at one second. They scan cached state and do not query PostgreSQL once preparation and cleanup are settled, so slowing them would delay readiness without helping the database become idle. Forward-ports [dd889a1](kagent-dev@dd889a1) to the current MCPServer and RemoteMCPServer controllers: discovery keeps its existing cadence, while unchanged catalogs skip PostgreSQL writes. Failed writes and deletion invalidate the cached observation so retries still reach the database. `LastConnected` records the last persisted connected observation. Uses the PostgreSQL pool configuration from kagent-dev#3032. Defaults and latency tradeoffs stay in the existing environment-variable reference, including the 30-second lateness window for cron firings. Validation: affected Go packages with the race detector, including an MCP test that closes the PostgreSQL pool before repeating unchanged discovery; Go lint; Helm controller/database tests; generated environment documentation check. --------- Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use database pool environment variables rendered by the helm chart
kagent/helm/kagent/templates/controller-configmap.yaml
Lines 69 to 82 in 4dce53d
in the
database.Connect. Defaults are pulled from pgx so if nodatabase.postgres.poolvalues are set there should be no behavior change.