Skip to content

Add a response inactivity timeout - #753

Open
star-sil wants to merge 1 commit into
pgjdbc:mainfrom
star-sil:gh-728
Open

star-sil wants to merge 1 commit into
pgjdbc:mainfrom
star-sil:gh-728

Conversation

@star-sil

@star-sil star-sil commented Sep 24, 2026 •

Copy link
Copy Markdown

Issue description

When server responses stop arriving, an outstanding exchange can remain pending and prevent normal resource cleanup. This adds an opt-in, connection-wide response inactivity timeout for #728.

The watchdog tracks inbound bytes before message framing, including partial responses. It runs while an exchange is outstanding and leaves idle connections alone. It pauses while received responses are buffered or COPY FROM STDIN awaits client input. On expiry, it closes the physical connection and fails outstanding exchanges with SQLSTATE 08006.

New Public APIs

  • PostgresqlConnectionConfiguration.Builder.responseTimeout(Duration)
  • PostgresqlConnectionFactoryProvider.RESPONSE_TIMEOUT, including the responseTimeout URL option
  • ConnectionSettings.Builder.responseTimeout(Duration)

Unconfigured, null, or zero disables the timeout. Negative durations and values exceeding Long.MAX_VALUE nanoseconds are rejected.

Additional context

This is an inactivity limit, not a total query deadline.

Closes #728.

Track inbound activity while protocol responses are outstanding.
Pause during buffered consumption and COPY input, then close the
transport and fail pending exchanges when the deadline expires.

Expose responseTimeout through configuration and connection URLs,
disabled by default. Cover scheduling, TCP framing, backpressure,
configuration, and PostgreSQL protocol boundaries with tests.

[resolves pgjdbc#728]
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.

Add an optional client-side read timeout for established connections

1 participant