Replies: 1 comment 4 replies
-
We'd need a complete example that demonstrates the problem to figure out what is going on. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using pgx v5.5.0.
I have a utility which uses pgxpool.
main() {
cfg := pgxpool.ParseConfig(...)
db, err := pgxpool.WithNewConfig(ctx, cfg) //(this also happens with just pgx.Connect())
defer db.Close()
rows = db.Query(...)
output, err := pgx.CollectRows(...)
rows.Close()
...print the output...
return
}
Every time I run it, I get a new active connection entry (with the state of idle) according to psql "select * from pg_stat_activity;" on the database:
datid | datname | pid | leader_pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait_event_type | wait_event | state | backend_xid | backend_xmin | query_id | query | backend_type
16511 | cjlicenses | 323400 | | 16489 | cj_license_manager | | 10.0.4.5 | | 36688 | 2024-02-26 15:45:03.548654+00 | | 2024-02-26 15:45:04.151007+00 | 2024-02-26 15:45:04.151068+00 | Client | ClientRead | idle | | | | SELECT id, vendor, feature, usage_state, last_state_change, reserved_by_node, used_by_process FROM license_state
...multiple of those lines, adds a new one each time I run the tool...
I've run it to the max_active_connections limit on the database, at which time it fails to connect, after which I had to destroy idle connections by hand to let it continue to work. (For reasons that escape me, gcp postgres at v14 doesn't appear to have the supported idle timeout setting, so there is no way of getting these connections dropped other than by hand.)
I've tried adding a cfg.AfterRelease to return false, which runs but didn't change the behavior.
Beta Was this translation helpful? Give feedback.
All reactions