Repository navigation
3.x.x: listen with a 4096 backlog (PRISM_STRATUM_LISTEN_BACKLOG) instead of mio's 128, so a reconnect burst doesn't overflow the accept queue - #723
Merged
Conversation
…ead of mio's 128 tokio's TcpListener::bind listens with mio's fixed backlog of 128, the standard library's value, so every native listener queued at most 128 connections before accept. On the pair, 400 simultaneous Stratum connects overflowed that queue 175 times (TcpExtListenOverflows), and HAProxy's layer-4 observation marked the frontend down. The 2.x.x runtime read PRISM_STRATUM_LISTEN_BACKLOG with a default of 1024; the native port had retired the name. listen::bind_listener binds as TcpListener::bind does (every resolved address in order, SO_REUSEADDR as mio sets it) but listens through tokio's TcpSocket with an explicit backlog. Both Stratum listeners take PRISM_STRATUM_LISTEN_BACKLOG, default 4096, 1 through 2147483647 (the listen(2) range), validated with the other Stratum settings. The kernel caps it at net.core.somaxconn without an error, so the "PRISM listening" line logs the backlog and the namespace's somaxconn, and a warning names the cap when somaxconn is lower. The audit/operator and public HTTP listeners use a fixed 1024. The setting moves from the retired inventory to the native one, with docs, .env.example and compose passthrough. Tests: a burst of 300 connects against a never-accepting listener with backlog 512 must all complete (133 of 300 complete against mio's 128), an address in use reports the bind error, and check-config enforces the range and the parse. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…ace, and the rollback hazard of the always-passed backlog setting From the review of #725: - The known issues add #724 to rc.3's list rather than claiming the rc.3 notes had it. - The pair evidence carried from rc.3 is named as rc.3's notes name it: the D1 peak-second gate, the 750/s ceiling and the failover drill run 1 on #719's build. "C10" is in no record. - Rolling a frontend back to rc.3 or earlier needs PRISM_STRATUM_LISTEN_BACKLOG removed first. This candidate's compose.yaml always passes it, and earlier builds in production mode refuse a set-but-unread PRISM_* setting. - rc.1 to rc.3 did not read the setting: they refused it in production, and elsewhere ignored it and listened with mio's 128. A carried 2.x.x value overrides the 4096 default. - #723's deployment-surface changes (compose.yaml, .env.example) are listed. Its CI proof is the unit test, and the pair's C5 re-run is the proof on the pair. - The log line is the primary listener's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.4: rc.3 plus #723 (the Stratum listeners listen with PRISM_STRATUM_LISTEN_BACKLOG, default 4096, instead of mio's fixed 128). Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.4.md covers: - the change and the pair's C5 finding (175 accept-queue overflows in a 400-connect burst, frontend A marked down, 158 sessions spilled to the backup); - upgrading: the setting is read again (rc.1 to rc.3 did not read it), no migration, somaxconn at least as high as the backlog, and removing the always-passed setting before rolling a frontend back to rc.3 or earlier; - the same evidence set as rc.3, with the pair evidence rc.3's notes cite carried; - the known issues carried from rc.3 and the #724 flake. The development-line notes name 3.0.0-rc.4, and they and the 3.0.0 notes link all four candidates' notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
rc.4 candidate. Do not merge during the rc.3 freeze.
On the pair, N2's C5 run opened 400 Stratum sessions at once, with no ramp, through HAProxy 3350 to A:3340. Three things went wrong:
ss -ltnshowed a Send-Q of 128, the listen backlog, on 0.0.0.0:3340, 3341 and 4334. That was despitenet.core.somaxconn= 4096 in that network namespace.nstatcountedTcpExtListenOverflows=TcpExtListenDrops= 175: the accept queue overflowed and the kernel dropped SYNs.observe layer4 error-limit 2 on-error mark-downmarked A down for about 4 s. 158 of the 400 sessions landed on the remote backup frontend and stayed there.The 128 doesn't come from the kernel or from our code.
tokio::net::TcpListener::bindcreates its socket with mio'sTcpListener::bind, and mio 1.2 listens with a fixed backlog of 128 to match the standard library (mio/src/net/tcp/listener.rs, "Use the same backlog value as the standard library"). Every native listener inherits it. The 2.x.x Python runtime readPRISM_STRATUM_LISTEN_BACKLOG, with a default of 1024, but the native port retired that name, so 3.x.x silently went from 1024 to 128.This PR binds every listener through a small helper,
listen::bind_listener. It does whatTcpListener::binddoes:SO_REUSEADDRas mio does, and leavesIPV6_V6ONLYat the system default;but it listens with an explicit backlog through
tokio::net::TcpSocket.PRISM_STRATUM_LISTEN_BACKLOG. The name comes back from the retired inventory, with a default of 4096. It accepts 1 through 2147483647, the rangelisten(2)takes, andcheck-configvalidates it with the other Stratum settings.net.core.somaxconnwithout an error. ThePRISM listeningline now logslisten_backlogand the namespace'ssomaxconn, and a warning names the cap when somaxconn is the lower. The pair's frontend namespace has 4096.The setting is documented in
docs/prism-configuration.md, listed innative-settings.txt(and removed fromretired-settings.txt), and passed throughcompose.yamland.env.example.Tests:
listen::tests::a_burst_beyond_mios_128_fits_the_configured_backlogbinds through the helper with a backlog of 512 and never accepts. It then opens 300 connections concurrently, each with a 2 s timeout, and requires all 300 to complete. With nothing accepting, a connect completes only while the accept queue has room; once the queue is full, the kernel drops the SYN.TcpListener::bind, which every listener used before this PR, and againstTcpSocket::listen(512), which the helper uses. On this host (net.core.somaxconn= 4096) it got 133 of 300 and 300 of 300, the same on both runs.listen::tests::an_address_that_cannot_be_bound_reports_the_bind_errorchecks that an address in use returns the bind error, asTcpListener::binddoes.config_cli::stratum_listen_backlog_is_checked_against_the_listen_rangechecks thatcheck-config:4kasinvalid PRISM_STRATUM_LISTEN_BACKLOG;Local runs:
cargo test -p qbit-prism-server --lib -- listen:: stratum::: 30 passed.cargo test -p qbit-prism-server --test config_cli(the new test and its Stratum and inventory neighbours): 7 passed.cargo clippy -p qbit-prism-server --lib --bins --tests -- -D warningsandcargo fmt --checkare clean.python3 scripts/check_prism_settings.pyandpython3 -m unittest tests.test_check_prism_settingspass.Review findings left out of this PR:
sysctls: net.core.somaxconnentry incompose.yaml. Kernels since 5.4 give every network namespace 4096 already, as the pair's has. A compose sysctl would also fail under host networking and some hardened runtimes. The new startup line and warning make a lower cap visible instead.Cutover note. Union averages about 20 sessions (p99 72, max 174), and the pair's LB-side mitigation and a connect ramp cover the cutover itself. This restores the headroom 2.x.x had and removes the 128-connection cliff behind any reconnect burst.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.