Repository navigation
network: cap the half-closed timeout at the historical 50s - #7
Merged
Merged
Conversation
Kukunin
force-pushed
the
haproxy-fin-conditional
branch
from
November 14, 2026 20:44
f99e001 to
ea000f1
Compare
The fin timeouts were emitted unconditionally at 30s, which tightened every deployment. haproxy falls back to "timeout client"/"timeout server" for half-closed connections when the fin timeouts are absent, so a zone on the 50000 default already bounded them at 50s and a 30s floor cut that without asking. Derive the value instead: min(idleTimeout, 50000), with idleTimeout=0 treated as unbounded and therefore capped. Two rules fall out of that. A half-closed connection is never held longer than 50000, the value hardcoded for every deployment before apache#12586 made the session timeouts configurable. And it never outlives an active one, because a timeout larger than idleTimeout would leave a dying connection with more budget than a working one. Everything at or below 50s is unchanged. Only zones above it are tightened, which is the case haproxy documents the directive for - FIN_WAIT buildup on long lived protocols such as RDP or WebSocket - and zones at 0, which had no bound at all. Indices 11 and 12 are written on every path rather than left to the array defaults. Arrays.asList wraps the static field without copying, so a set() writes through to it and persists for the life of the JVM; assigning both slots unconditionally keeps the rendered config dependent only on this invocation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Kukunin
force-pushed
the
haproxy-fin-conditional
branch
from
November 14, 2026 20:48
ea000f1 to
76e5b62
Compare
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.
Follow-up to #6, which emitted the fin timeouts unconditionally at 30s. The upstream review on apache#14700 caught that this tightens every deployment, and it was right.
Why
Per the haproxy docs, when the fin timeouts are not set, half-closed connections fall back to
timeout client/timeout server:So half-closed connections are already bounded wherever
idleTimeout > 0, and a flat 30s silently cut that — a zone on the 50000 default went 50s → 30s with no way back.But the opposite extreme is also wrong. A zone with a 1hr idle timeout currently holds half-closed connections for an hour, which is exactly the FIN_WAIT buildup the directive exists to prevent:
What changed
The value is derived rather than fixed:
min(idleTimeout, 50000), withidleTimeout = 0treated as unbounded and therefore capped.idleTimeout03600000(1hr)50000(default)1234< 0Two rules fall out of that:
idleTimeout— a half-closed connection should not get more budget than an active one.Everything at or below 50s is untouched, so most deployments see no change. Only zones above 50s are tightened — the case the docs describe — and zones at 0, which had no bound at all.
Note on the static array
Indices 11 and 12 are written on every path rather than left to the array defaults.
Arrays.asListwraps theprivate staticfield without copying, soset()writes through and persists for the life of the JVM; a network rendered once would otherwise leak its values into every network rendered afterwards. Assigning both slots unconditionally keeps the output dependent only on the current invocation. The underlying mutation issue is left alone.Testing
HAProxyConfiguratorTestpasses (5 tests, 0 failures), covering all three interesting cases:0 → 50000,1234 → 1234,3600000 → 50000.To validate once the deb builds: us-central1 runs
idleTimeout=0, so it exercises the capped branch and should rendertimeout client-fin 50000. Regenerate the VR config, confirm the value, restart haproxy, then re-run the socket-persistence check that previously showed 0 of 332 half-closed sockets surviving 75s.apache#14700 will be updated to this shape once validated.
🤖 Generated with Claude Code