Skip to content

Conversation

yuliy-openai
Copy link
Contributor

If _can_use_connection fails (say, because of an asyncio timeout), then we may have a full connection that has been created but would be leaked by this function. (note: _connect_addr takes care of cleaning up after itself if it fails partway)

This is particularly possible in the case of pgbouncer, where we may succeed at establishing a connection much quicker than even a trivial call to the backing database would take.

I believe this failure mode was introduced in #987

I'm not certain if we should await here or just punt the closing of the other connections to a background task (I don't know how risky close is on an established connection).

@elprans elprans closed this Oct 11, 2025
@elprans elprans reopened this Oct 11, 2025
Copy link
Member

@elprans elprans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for the fix!

@elprans elprans merged commit e94302d into MagicStack:master Oct 11, 2025
110 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants