Skip to content

Fix PgEncoder to fully close the connection on idle timeout - #1756

Open
tsegismont wants to merge 1 commit into
eclipse-vertx:masterfrom
tsegismont:issue/1755
Open

tsegismont wants to merge 1 commit into
eclipse-vertx:masterfrom
tsegismont:issue/1755

Conversation

@tsegismont

Copy link
Copy Markdown
Member

See #1755

PgEncoder.close() used channel.shutdownOutput() to send EOF after the Terminate message. This is a TCP half-close: the client sends FIN but waits for the server's FIN before channelInactive fires. When the server is unresponsive the channel hangs open indefinitely, which means ch.closeFuture() never completes and the connection is never released.

Replace shutdownOutput() with ctx.close() so the full Netty close is initiated from the client side immediately after flushing the Terminate message, regardless of whether the server responds.

Also propagate ctx.close(promise) in the overridden Netty close handler so the pipeline promise is completed rather than silently dropped.

Add testReadIdleTimeoutClosesConnection: a raw Java ServerSocket completes the PG handshake then stays silent. With readIdleTimeout=200ms the idle handler fires and closes the channel. Without the fix the closeHandler never fires and the test times out.

Assisted-By: Claude Sonnet 4.6

See eclipse-vertx#1755

PgEncoder.close() used channel.shutdownOutput() to send EOF after the Terminate message.
This is a TCP half-close: the client sends FIN but waits for the server's FIN before channelInactive fires.
When the server is unresponsive the channel hangs open indefinitely, which means ch.closeFuture() never completes and the connection is never released.

Replace shutdownOutput() with ctx.close() so the full Netty close is initiated from the client side immediately after flushing the Terminate message, regardless of whether the server responds.

Also propagate ctx.close(promise) in the overridden Netty close handler so the pipeline promise is completed rather than silently dropped.

Add testReadIdleTimeoutClosesConnection: a raw Java ServerSocket completes the PG handshake then stays silent.
With readIdleTimeout=200ms the idle handler fires and closes the channel.
Without the fix the closeHandler never fires and the test times out.

Assisted-By: Claude Sonnet 4.6
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>

@vietj vietj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the test should avoid using java net socket

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.

2 participants