Repository navigation
fix: keep the password and the session settings when reconnecting - #478
LemonCondor wants to merge 1 commit into
Conversation
try_reconnect() only reused the parameters reported by libpq, which never include the password, and did not set up the new session again.
|
Hi !, thanks for contributing. I love the For the password, while the current state is not satisfactory, I am not fond of keeping the |
|
Thanks for the review. I can split this, so that For the password, one option which avoids storing it in Tell me which you prefer, or if you would rather think about it first. |
After a lost connection,
Data.try_reconnect()opens a new one fromdsn_parametersonly. Two things are missing:pg_activitystays on "trying to reconnect".--hide-queries-in-logsno longer applies (the tool's queries are logged again), andintervalstyleis not set. On a server whose default isiso_8601, the next refresh raisesNotImplementedError: can't parse interval with IntervalStyle 'iso_8601'.All three symptoms reproduce against PostgreSQL 17 with password authentication (terminating the backend, then reconnecting).
The change keeps the password supplied by the user (excluded from
repr) andhide_queries_in_logson theDataobject, and moves the session setup into one method used by both connection paths. Passwords coming fromPGPASSWORDor.pgpassare still read by libpq as before.The new tests in
tests/test_data.pyfail onmasterand pass with the change. On a fork, the Tests and Lint workflows pass (103 passed, 1 skipped on Python 3.10 and 3.14). Thepsycopg2code path was not run.