Repository navigation
fix: QUIC in the default build with Retry under load, bwlimit sleep like upstream - #8229
Merged
Merged
Conversation
14 of 15 tasks
…eue sleeper The bandwidth limiter only sleeps once the owed delay reaches 100 ms (upstream io.c:2323-2356 sleep_for_bwlimit, which then blocks in select()), so the kqueue EVFILT_TIMER sleeper never used its sub-millisecond resolution. Remove fast_io::TimerSleeper, the limiter backend switch and the OC_RSYNC_BWLIMIT_BACKEND selector, and sleep with std::thread::sleep on every platform. bandwidth no longer depends on fast_io.
Replace elapsed-time upper bounds, which fail on a loaded runner, with checks whose outcome cannot depend on scheduling: - AsyncRateLimiter tests run on tokio's paused clock and assert exact virtual durations and token counts. - The goodbye timeout fixture counts the reads issued after the prefix instead of sleeping to a deadline, so "waited once" and "did not retry" are exact counts. - Waits that a regression would turn into an unbounded block now use an unbounded or hour-long budget, so the harness timeout is the guard. - Assertions already implied by a returned value, an exit code or a typed error are removed, as are perf budgets in correctness tests.
The testsuite and interop log uploads are diagnostics no later job downloads. A GitHub artifact ETIMEDOUT after every cell passed was failing the job. Build, release, fuzz and benchmark uploads stay fatal.
poll_ready takes its PollTimeout and KqueueAcceptEngine::new its kevent wait bound instead of reading a constant. Production passes the same 50 ms / 100 ms signal-check cadence. The readiness tests pass no bound at all, so only a real connection can end the wait: a sleep-then-probe regression now hangs the test instead of passing slowly under a wall-clock ceiling.
- The un-throttled QUIC control checks the limiter's recorded-sleep session is empty instead of a wall-clock ceiling; both pacing tests assert whether the writer carries a limiter. - The QUIC teardown latency bound is dropped: the driver's 100 ms MAX_SLEEP keeps teardown bounded, so it only measured latency, which the benches and perf gate own. - The connect-watchdog tests block on the killed child closing its stdout instead of sleeping past the timeout, and the networked smoke test checks the latched TimedOut rather than elapsed time. - ThrottlingWriter::is_throttled now has a caller; drop its stale dead-code allowlist row.
The daemon loaded its QUIC identity only when the QUIC front process started. A cert/key mismatch was logged and the daemon kept serving TCP with no QUIC listener, so the operator could not tell QUIC was down. Load the identity at startup with the other QUIC config checks and exit 1, the same as a missing cert or key. rustls reports the mismatch as KeyMismatch; the error now says the private key does not match the certificate.
The QUIC listener runs in a forked front process and exists only on Unix. A Windows daemon with a quic directive started TCP-only and gave no sign that QUIC was ignored. It now fails config parsing with exit 1 and names the directive. The Windows CI job runs the test.
Release builds for Linux gnu, Linux musl (pure and vendored OpenSSL), macOS and Windows now enable the quic feature. The transport stays an opt-in quic:// operand and the feature is not a default. On Windows only the client applies: the daemon refuses quic directives. FreeBSD is not built by this workflow. A new non-required linux-musl-quic job builds the static musl binary with quic, since the musl release tarballs now depend on it.
The two mutual-TLS client flags were the only QUIC options missing from --help and from the OC_EXTENSION_FLAGS registry, so surface_diff kept them as accepted exceptions. Both now render under the QUIC heading, the registry carries every --quic* flag, and the stale accepted entries are gone. The extension env reference gains OC_RSYNC_QUIC_CC and OC_RSYNC_QUIC_WINDOW.
A disk error raised before a file's Commit (backup, writer setup, append-verify prefix read, or a chunk write) returned without consuming the rest of that file's queued messages. The disk thread then answered each leftover chunk with a separate error result, filled the bounded result queue and blocked, while the network thread blocked sending the next chunk. The transfer stalled until the peer's idle timeout, which is the intermittent QUIC push stall. Route every pre-Commit error exit through the existing open-failure drain, mirroring upstream discard_receive_data() (receiver.c:1254-1261).
Mint every certificate shape with rcgen at test time and drive the real daemon and client over loopback, pull and push, pinning the exit code and a stable stderr fragment per row: accepted chains (DNS and IP SANs, an intermediate, P-256/P-384/Ed25519/RSA-2048 keys), refused server leaves (CA:TRUE, SAN mismatch, missing serverAuth, expired, not yet valid, unknown issuer), daemon identity load failures, client trust file errors and the mutual TLS cases. Run the matrix in the linux-quic job and make docs/quic-transport.md state the same rules, naming the test as their source of truth.
… files Expired and not-yet-valid certificates in the validation matrix now take windows relative to the current time instead of fixed years. A new lint step fails when a key or certificate file, a PEM block with a body, or a base64 DER blob is checked in. The only allowance is the short malformed-key parse-error input in rsync_io quic/trust.rs, named by exact path; a real-length body is reported even there.
A test helper named serve made the name-based dead-code census treat the unused async_session listener serve() as referenced.
oferchen
force-pushed
the
refactor/bwlimit-sleep-like-upstream
branch
from
October 21, 2026 03:46
04a6ec7 to
b0e0e72
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.
Summary
bwlimit sleep and deterministic timing tests
io.c:2323-2356 sleep_for_bwlimit()sleeps only once the owed delay reaches 100 ms, then blocks inselect(). oc keeps the sameMINIMUM_SLEEP_MICROSfloor, so the macOS kqueueEVFILT_TIMERsleeper never used its sub-millisecond resolution.fast_io::TimerSleeper, the limiter backend switch andOC_RSYNC_BWLIMIT_BACKEND.--bwlimitnow sleeps withstd::thread::sleep(nanosleep) on every platform.bandwidthno longer depends onfast_io.poll_readytakes aPollTimeoutandKqueueAcceptEngine::newtakesOption<Duration>.TimedOut.MAX_SLEEPkeeps teardown bounded, so the bound measured latency only.QUIC hardening and disk-error drain
ENOSPC, a failed open, an inplace backup or an--append-verifyprefix read) used to return without draining that file's queued chunks. The network thread then blocked on a full channel forever: the daemon worker hung and a QUIC push stalled into a timeout. Every pre-commit error exit now drains, as upstream'sdiscard_receive_data()does (receiver.c:1254-1261).--quic-certand--quic-keyin--help, and pin the certificate validation matrix with tests that mint their certificates withrcgenat run time.QUIC in the default build, Retry under load,
quic addressquicjoins the default cargo features (next toembedded-ssh). Runtime stays admin opt-in, as SMB over QUIC does: a client uses QUIC only forquic://or--quic, and a daemon listens only whenquic cert fileandquic key fileare set. A--no-default-featuresbuild refusesquic://and--quicwith "not compiled into this build". Measured cost (Linux x86_64 release): 15,355,480 to 17,165,920 bytes (+1.81 MB, +11.8%), 406 to 420 crates.rsync_io::quic::admissionadds aRetryPolicy { Never, UnderLoad { threshold }, Always }with a pureadmit(validated, handshaking)decision, driven by the new global directivequic retry = auto|always|never(defaultauto). The threshold is 100 in-flight handshakes, HAProxy'stune.quic.retry-thresholddefault. MsQuic (SMB over QUIC) and HAProxy both default to Retry under load; quinn never sends Retry on its own (Incoming::retry()), and RFC 9000's mandatory 3x anti-amplification limit stops reflection, not state exhaustion. Tokens use quinn's 15 s lifetime and per-process key.max_incoming = min(max connections, 128), 64 KiB per attempt, at most 8 MiB in total (quinn's defaults are 65536 / 10 MiB / 100 MiB).quic address = <ip> [<ip> ...]: a global-only list of literal IPv4/IPv6 addresses that binds the QUIC listener independently of TCPaddress, e.g.quic address = 127.0.0.1 ::1for a dual-stack loopback listener. Unset, QUIC keeps following the TCP addresses, which are dual-stack ([::]and0.0.0.0) with a per-family fallback. A listed address that fails to bind stops the daemon and names the address. Hostnames, bad IPs, duplicates and module-scope use are refused; a Windows daemon refuses it like the otherquic *directives.test_support::LogLines, a blocking read of the daemon's stderr log), replacing a polled file with a deadline. They wait for the IPv4 "serving on" line specifically, fixing a latent race.Details
QUIC hardening and disk-error drain
Disk-error drain
crates/transfer/src/disk_commit/process/file_ops.rs: the five error exits that returnedErr(err)directly now go throughdiscard_file_messages(), which consumes the file's remainingChunk/MatchedChunk/SkipMatchedmessages up to itsCommit. Buffers go back to the network thread, and the first error is reported. The open-failure exit already did this.Evidence (physical Linux host, against
/usr/bin/rsync3.5.1):Mutation check. All five sites were reverted to a bare
return Err(err).Unit tests:
disk_commit::tests::setup_error_drains_the_files_remaining_messagesdisk_commit::tests::chunk_write_error_drains_the_files_remaining_messagesEnd to end: a push into a daemon module on a 1 MiB tmpfs, so the receiver hits
ENOSPC. "Leftover workers" counts daemon children beyond the one an idle daemon always has.timed outafter about 30 sEach mutant worker that deadlocked stayed alive for 10+ minutes, with both its main thread and its
disk-committhread parked infutex_do_wait. It survived the daemon's shutdown signal and had to be killed by PID. With the fix, every run exits promptly with upstream's code, 11 (RERR_FILEIO).QUIC daemon identity and platform refusals
crates/daemon/src/daemon/runtime_options/quic_identity.rs: the daemon loadsquic cert fileandquic key file, checks that the key matches the leaf certificate, and exits 1 at startup if it doesn't. Without the check, the listener would come up and fail every handshake.runtime_options/parsing.rs: a Windows daemon refuses anyquic *directive with a clear error, since the QUIC daemon is not supported there.Release artifacts, help and docs
.github/workflows/ci.ymlandrelease-cross.ymlbuild thequicfeature into release artifacts and the musl build.--helplists--quic-cert/--quic-key. The environment reference documentsOC_RSYNC_QUIC_CCandOC_RSYNC_QUIC_WINDOW.Certificate validation matrix
crates/transfer/tests/quic_certificate_validation_matrix.rs(withquic_daemon_identity_mismatch_fails_startup.rs, 32 tests) covers:Validity windows come from the clock. Keys are generated with
rcgenper run.tools/ci/check_no_key_material.pyfails CI if PEM key or certificate material is committed.Test plan
bwlimit sleep and deterministic timing tests
CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl.
Local gates (Linux):
check_rustfmt_all.py;--all-targets --all-features -D warningson every touched crate;dead_code_census,unsafe_owner_deps,no-placeholders.macOS is gated by CI only: the kqueue engine and the
fast_iokqueue module cannot be cross-built here (jemalloc's C build).Targeted nextest passes, including
--features quicandembedded-ssh. The networked SSH watchdog test also passes withOC_RSYNC_SSH_NET=1.Mutation checks; each mutation turns its test red:
poll_readyignores readinessthrottled_writerdrops the limiterfiredThe reworked daemon, QUIC and SSH tests passed 30/30 runs with every core busy.
Daemon accept syscall gate (strace -c, 20 connections), before and after the seam: 21
accept4, 23polland 42ppolleach, with totals of 3147 and 3150 (idle noise).--bwlimit=500Kon a 2 MiB local copy: 4.020 s over 3 runs, against 4.096 s expected (-1.9%). strace showed 112clock_nanosleep. Linux already used the std backend, so its syscall profile does not change.QUIC hardening and disk-error drain
cargo fmt --all -- --checkandpython3 tools/ci/check_rustfmt_all.pycargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo check --target x86_64-pc-windows-gnu -p daemon -p cli -p transfer -p rsync_io --all-features --testscargo nextest run -p transfer -p daemon -p cli -p rsync_io -p test-support --all-features -E 'test(/quic|drain|help|runtime_options|disk_commit/)': 756 passedcargo nextest run -p transfer --all-features -E 'binary(quic_certificate_validation_matrix) | binary(quic_daemon_identity_mismatch_fails_startup) | test(/disk_commit::/)': 184 passed (32 QUIC integration tests)python3 tools/ci/check_no_key_material.py,unsafe_owner_deps.py,dead_code_census.py,cargo run --locked -p xtask -- no-placeholders,cargo run --locked -p xtask -- citationstools/ci/upstream-3.5.1-expect.nonroot.txt, on the physical Linux host. Branch and master (0fe3a72) give the identical result: 274 passed, 1 failed, 85 skipped. Both carry the same two host-only manifest mismatches:protected-regularpasses where the manifest expects a skip (the host hasfs.protected_regular=1), andrrsync-userns-procfsfails. No regression.QUIC default build, Retry and
quic addressalwayssends a Retry and still completes; a ServerConfig test that the incoming limits are applied; parse tests forquic retryandquic address; resolver tests (set vs unset, unset stays dual-stack).quic retry = alwayslogs the Retry line, and underneverdoes not. TCP on the wildcard with QUIC on127.0.0.1 ::1, where the bound-address log line equals the configured list.>=to>,Alwaysforced to accept, max_incoming ignored, limits not applied, directive dropped, admission unwired;quic addressignored, explicit bind failure tolerated, duplicate check removed, bad entries accepted. Readiness: a 12 s delay in the QUIC front still passes.docs/quic-transport.mdwalkthrough on a DEFAULT build: 18/18. Withquic address = 127.0.0.1 ::1,ss -ulpnshows UDP only on 127.0.0.1 and ::1 while TCP stays on both wildcards.cargo check --workspace --all-features --tests, both clippy runs (all features and default features),--no-default-featurescheck, 684 targeted tests on the rebased tree.Coordination
bwlimit sleep and deterministic timing tests
QUIC hardening and disk-error drain
disk_commitwas last changed by perf: cut sender seeks and receiver signature allocations #8210 and fix: keep local-copy output and exit codes in line with upstream #8222; this branch is rebased onto c8cd64a.Conventional commit prefix
fix:- QUIC daemon refusals and the disk-error drain are fixes; the bwlimit sleeper removal and test rewrites ride along as refactor/test work.Security considerations
bwlimit sleep and deterministic timing tests
poll_readyand the macOS kqueue accept engine now take their wait bound as a parameter; production passes the same 50 ms / 100 ms as before, so accept, timeout and shutdown behaviour is unchanged.SECURITY.mdchange).QUIC hardening and disk-error drain
daemon_cert_and_key_mismatch_exits_1,quic_daemon_identity_mismatch_fails_startup).runtime_options_quic_windows_refusal).docs/quic-transport.md,SECURITY.md.Pre-merge checklist
cargo fmt --allrun locally.CHANGELOG.mdupdated if user-visible (Removed: the env var and the kqueue sleeper; replace#8229once the PR number is known).SECURITY.mdupdated if security-relevant. Not applicable.