Bound HTTP client timeouts and reclaim pooled connections#317
Open
namedgraph wants to merge 1 commit into
Open
Bound HTTP client timeouts and reclaim pooled connections#317namedgraph wants to merge 1 commit into
namedgraph wants to merge 1 commit into
Conversation
Fixes connection-pool exhaustion: a stalled read on the end-user backend route was held indefinitely because the pooled HTTP clients had no socket/read timeout (Apache default SO_TIMEOUT = 0 = infinite). The worker thread blocked inside the read and never reached Response.close(), so the leased connection was never returned. With connectionRequestTimeout also unset, new requests blocked forever waiting for a lease instead of failing fast, wedging the listener. Adds socket timeout, connect timeout, connection TTL and validate-after-inactivity to the pooled HTTP clients, applied only when configured. Values are supplied via env vars through the existing CATALINA_OPTS -> system property -> JAX-RS app constructor convention (as connectionRequestTimeout already is), with image defaults in the Dockerfile -- no hardcoded values in Java: CLIENT_SOCKET_TIMEOUT -> ...linkeddatahub.socketTimeout CLIENT_CONNECT_TIMEOUT -> ...linkeddatahub.connectTimeout CLIENT_CONNECTION_TIME_TO_LIVE -> ...linkeddatahub.connectionTimeToLive CLIENT_VALIDATE_AFTER_INACTIVITY -> ...linkeddatahub.validateAfterInactivity SignUp: close the PublicKey/Agent/Authorization client Responses on all paths (defense-in-depth; these leaked on the admin signup path). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes connection-pool exhaustion: a stalled read on the end-user backend route was held indefinitely because the pooled HTTP clients had no socket/read timeout (Apache default SO_TIMEOUT = 0 = infinite). The worker thread blocked inside the read and never reached Response.close(), so the leased connection was never returned. With connectionRequestTimeout also unset, new requests blocked forever waiting for a lease instead of failing fast, wedging the listener.
Adds socket timeout, connect timeout, connection TTL and validate-after-inactivity to the pooled HTTP clients, applied only when configured. Values are supplied via env vars through the existing CATALINA_OPTS -> system property -> JAX-RS app constructor convention (as connectionRequestTimeout already is), with image defaults in the Dockerfile -- no hardcoded values in Java:
CLIENT_SOCKET_TIMEOUT -> ...linkeddatahub.socketTimeout
CLIENT_CONNECT_TIMEOUT -> ...linkeddatahub.connectTimeout
CLIENT_CONNECTION_TIME_TO_LIVE -> ...linkeddatahub.connectionTimeToLive
CLIENT_VALIDATE_AFTER_INACTIVITY -> ...linkeddatahub.validateAfterInactivity
SignUp: close the PublicKey/Agent/Authorization client Responses on all paths (defense-in-depth; these leaked on the admin signup path).