Skip to content

fix: Mark a host offline when the connection attempt times out - #6740

Open
mt89vein wants to merge 1 commit into
npgsql:mainfrom
mt89vein:fix-multihost-host-slow-response
Open

mt89vein wants to merge 1 commit into
npgsql:mainfrom
mt89vein:fix-multihost-host-slow-response

Conversation

@mt89vein

@mt89vein mt89vein commented Nov 3, 2026 •

Copy link
Copy Markdown

A host that accepts TCP but never answers the startup handshake stayed in the Unknown state. The read timeout breaks the connector while it is still Connecting, which intentionally skips marking the host offline, and the following Break from Open returns early because the connector is already Broken.

Mark the host offline when the final Open attempt fails too, so subsequent connections skip it until Host Recheck Seconds expires, like a host that refuses connections.

with fix, we can see this in output from issue for both cases (tested on real multihost pg)

   open #1:   2067 ms
   open #2:      4 ms
   open #3:      4 ms
   open #4:      3 ms
   open #5:      3 ms

Fixes #6733

A host that accepts TCP but never answers the startup handshake stayed in the Unknown state. The read timeout breaks the connector while it is still Connecting, which intentionally skips marking the host offline, and the following Break from Open returns early because the connector is already Broken.

Mark the host offline when the final Open attempt fails too, so subsequent connections skip it until Host Recheck Seconds expires, like a host that refuses connections.

Fixes npgsql#6733

This branch has not been deployed

No deployments
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.

Multi-host: a host that accepts TCP but never responds is never marked offline, so every new connection waits for the full Timeout

1 participant