[Feature] Add configurable connect_timeout to pgjsonb returner #69050
co-cy
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
salt/returners/pgjsonb.pycallspsycopg2.connect()withoutconnect_timeout. When the database is reachable on the network but does not respond — stalled standby, firewall drop, HAProxy or Sentinel mid-failover — the connect call blocks for tens of seconds on the system TCP timeout. Bothevent_returnandclean_old_jobsrun inside the master event loop, so one stalled connect cascades into delayed events and slow returns across the whole master.The other PostgreSQL libraries Salt links against (e.g.
psycopg2.connect) already acceptconnect_timeout, but pgjsonb does not expose it as a config option, so operators have no way to bound the wait short of patching Salt.Describe the solution you'd like
Add an optional
returner.pgjsonb.connect_timeout(seconds) that is forwarded topsycopg2.connect(connect_timeout=...)only when set. With no default, the kwarg is omitted entirely, so libpq's default behaviour stays in force for existing deployments — operators opt in.Describe alternatives you've considered
statement_timeoutinstead. Different scope — that bounds query duration, not connect duration. Both might be useful eventually; this PR covers connect only.Additional context
The accompanying PR also handles the case where the timeout is delivered as a string (pillar / env) by coercing it to int in
_get_options, mirroring the existing treatment ofport. Three behavioural tests cover: backwards-compat default (kwarg omitted), opt-in path (kwarg forwarded verbatim), and string-to-int coercion.Affected branches:
3006.x,3007.x,3008.x,master.Beta Was this translation helpful? Give feedback.
All reactions