Skip to content

Do not wait for a connection closure - #8

Merged
Pliner merged 2 commits into
Pliner:mainfrom
slawwan:no-wait-connection-close
Oct 6, 2026
Merged

Pliner merged 2 commits into
Pliner:mainfrom
slawwan:no-wait-connection-close

Conversation

@slawwan

@slawwan slawwan commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

If the lock connection dies silently (no FIN/RST, e.g. after a network blip), __ensure_connection_established hangs forever on await asyncio.shield(connection.close()): asyncpg cancels the in-flight keep-alive query and waits for the cancellation result on the dead connection without a timeout. The lock is never reacquired.

The fix closes the connection in background, the same as in asyncpg-listen#223.

test_reacquire_lock_after_silent_disruption reproduces it via TcpProxy.freeze_connections(): fails on main, passes with the fix.

@slawwan
slawwan requested a review from Pliner October 6, 2026 07:44
@slawwan
slawwan marked this pull request as ready for review October 6, 2026 07:44
@Pliner

Pliner commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Seems to be related to MagicStack/asyncpg#1361, it should be dropped when asyncpg is fixed

@Pliner
Pliner merged commit 5cd9889 into Pliner:main Oct 6, 2026
4 checks passed
@slawwan
slawwan deleted the no-wait-connection-close branch October 6, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants