Repository navigation
Free Query Tool results when connections are released, and release the rest when one fails. #10890 - #10916
Conversation
…e rest when one fails. pgadmin-org#10890 Connection._release() closed the database connection but kept the cursor of the last asynchronous query, and with it every row that query had fetched, so a Connection object that outlived its release kept the whole result set in memory. The cursor is now closed and dropped as well. ServerManager.release() cancelled each connection's transaction and then closed it with no error handling, so an exception from one connection (such as a saved password that could not be decrypted) stopped the remaining connections being closed and left all of them in the manager, to fail again on every idle-session sweep. Failures are now logged and the remaining connections are still released. When another user's request runs the idle-session cleanup, cancel_transaction() no longer tries to decrypt the saved password with that user's key, and connects without it instead. Closes pgadmin-org#10890
|
No actionable comments were generated in the recent review. WalkthroughThe changes update psycopg3 connection cleanup to close asynchronous cursors, handle per-connection failures during manager release, and avoid decrypting a saved password when the connection belongs to another pgAdmin user. Regression tests cover these cases. ChangesConnection Cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Possibly related PRs
Suggested reviewers: Merge Risk:
|
…g#9261 CancelOtherUsersTransactionTest, from pgadmin-org#10916, mocks a manager with no auth_method, which cancel_transaction() takes for a token method and cancels with libpq's cancel request. The test is about decrypting a saved password, which only a password server does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Connection._release()now closes and drops the cursor of the last asynchronous query. Previously a releasedConnectionthat was still referenced kept every row that query had fetched, which is the multi-GB retention in the report.ServerManager.release()logs and carries on when cancelling or closing one connection raises, so one bad connection no longer leaves the whole manager unreleased (and failing again on every idle-session sweep).cancel_transaction()no longer decrypts the owner's saved password with the current user's key; it connects without it instead. TheUnicodeDecodeErroritself was already handled on master by fix: don't hard-fail on an undecryptable saved password #10174.Test plan
utils.driver.psycopg3.tests.test_release_connections(fails on master, passes here)utils.driver.psycopg3.tests,tools.sqleditor.tests.test_poll_query_tool,test_connect_keeps_tool_connections,test_check_connectagainst PostgreSQL 18pycodestyleon the changed filesCloses #10890
Summary by CodeRabbit