Repository navigation
test: calibrate the watchdog deadline and pin shutdown's teardown report - #1869
Merged
Merged
Conversation
…checkpoint cost A fixed 600ms unit deadline is load-flaky: a contended runner can move 4MiB slower than it, falsely reassigning the healthy lane. Time one checkpoint through a fresh lane first, then rest the deadline a factor above it, floored for fast machines and capped well under the 20s outer bound.
…n a ShutdownReport Pin SHUTDOWN_TIMEOUT > ABANDON_DRAIN_CAP at compile time (mirroring the CONVERGENCE_ROUND_TIMEOUT pattern) so a ceilinged drain can never consume the whole budget. Have support::shutdown return a ShutdownReport carrying the reaped/closed counts so a caller can assert on a breach rather than only see the warning line, and pin both behaviors under start_paused: the clean counts, and a stalled close (endpoint whose close() blocks on a never-draining connection) that still yields Ok with closed < M.
The module header's 'introduced in PR #673' is changelog voice; state the present capability. Rename find_providers_negative_cache_expires_after_ttl to say what it asserts: the lookup stops suppressing once the negative entry expires.
There was a problem hiding this comment.
Pull request overview
This PR improves test reliability and teardown observability across decdn-client-pull and decdn-node, addressing flakiness and making teardown deadline breaches assertable rather than only logged.
Changes:
- Calibrate the client-pull watchdog
unit_deadlineat runtime in the flaky scheduler test to reduce load sensitivity. - Add a compile-time invariant pin (
SHUTDOWN_TIMEOUT > ABANDON_DRAIN_CAP) and return aShutdownReportfromsupport::shutdownso breach counts can be asserted in tests. - Clean up
dht_integration.rsheader wording (remove changelog voice) and rename a negative-cache test for accuracy.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/client-pull/src/scheduler.rs | Adds calibrated_unit_deadline() and uses it in the watchdog reassignment test to reduce load flakiness. |
| crates/node/tests/support/mod.rs | Adds compile-time teardown/drain cap ordering assertion and changes shutdown to return ShutdownReport. |
| crates/node/tests/support_teardown.rs | Adds tests asserting clean shutdown counts and a stalled-close breach scenario under start_paused. |
| crates/node/tests/node_origin_pull.rs | Updates a direct-return caller to account for shutdown() now returning a report. |
| crates/node/tests/dht_integration.rs | Removes changelog voice from module header and renames a test to match behavior. |
| crates/node/src/node_origin/mod.rs | Exposes abandon_drain module to allow integration tests to name the drain cap. |
| crates/node/src/node_origin/abandon_drain.rs | Makes ABANDON_DRAIN_CAP public so integration tests can assert teardown invariants. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.08% (was 82.07%, ▲ +0.01%) — 68127/83002 lines
History
|
…wedge budget The close-path teardown test ran on a paused clock with its endpoint driver on another thread. A paused clock auto-advances past the deadline the moment the runtime idles, so the breach was manufactured by the clock rather than by the stranded connection: the test passed with the whole strand apparatus removed, and with no connection at all. Run the close paths on the real clock under a caller-chosen deadline, and pair the breach test with a control that dials the same peer and leaves the driver running. Flipping the strand off now fails the breach test, which is what makes it coverage of #1675 rather than of tokio's virtual clock. ShutdownReport carries its own denominators so is_clean() replaces a hardcoded endpoint total in the assertion, and the const assert pins the 1.5x margin its prose calls the sole derivation of SHUTDOWN_TIMEOUT, in nanoseconds. The wedge test's outer bound now rides on the same measurement as its unit deadline — a fixed bound against a scaled deadline only relocates the flake — the calibration takes the ceiling instead of failing the test under a lane-fault message when it trips its own watchdog, and it says so on stderr when the safety factor is capped. Its comment named a 20 s wedge; the wedge is 120 s. ABANDON_DRAIN_CAP is a doc-hidden re-export rather than a public module, so the one constant the test needs is the only thing exposed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EdRw9i5zQDZEmQQnr94LJ5
A stalled close pinned only the `closed` counter. The docstring claims both readings, and `reaped` short of N is the diagnosis that names this fixture's own defect rather than the stranded driver #1675 tracks. An abort only drops a task's future at its next poll, so a task that never yields never takes it. `spawn_blocking` parks one honestly, on a blocking-pool thread rather than a runtime worker, and waiting on a start signal first rules out the cancellation path that would reap cleanly instead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EdRw9i5zQDZEmQQnr94LJ5
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
Closes #1840.
Rust-side hygiene + a teardown contract, covering all four of that issue's sub-items. Three independent changes on
main's test/impl surface; wire-breaking shapes are untouched.1. Load-flaky watchdog test (
crates/client-pull)wedged_source_is_ended_by_the_watchdog_and_its_tail_reassignedused a fixed 600 msunit_deadline, which is load-flaky: a contended runner can move a checkpoint slower than that, so the healthy lane gets falsely reassigned.calibrated_wedge_budget()times oneClientRangedStore::INGEST_CHECKPOINT_BYTEScheckpoint through a fresh lane first, then sizes the deadline a factor (10×) above it — floored for fast machines, capped at 5 s. Both of the test's deadlines come from that one measurement: the outer bound is4 × unit_deadline + 15 s, because a fixed bound against a scaled deadline only relocates the flake (the watchdog needs up to two windows to trip, and the surviving lane then refetches the wedged tail).CHECKPOINTis derived fromINGEST_CHECKPOINT_BYTES(nowpub(crate)) instead of duplicating4 * 1024 * 1024.2. Teardown deadline → drain cap, and a
ShutdownReportABANDON_DRAIN_CAPis exposed as a#[doc(hidden)] pub use; theabandon_drainmodule stays private, so the one constant the test needs is the only thing on the surface.SHUTDOWN_TIMEOUT's docstring calls the 1.5× margin over the drain cap "the sole derivation of the number", so the compile-time assertion pins that ratio — in nanoseconds, sinceas_secs()truncates.support::shutdownreturnsanyhow::Result<ShutdownReport>, carryingreaped/closedagainst the totals it was handed sois_clean()replaces a hardcoded endpoint count in the assertions. Existing callers use.await?and need no change (one direct-return caller updated).shutdown_within(deadline, …)lets the helpers' own suite choose a deadline it can sit through; every other caller still getsSHUTDOWN_TIMEOUT.The close tests run on the real clock, and that is load-bearing. A paused clock auto-advances past a deadline the instant the runtime idles, which manufactures a breach whatever the endpoint is doing — a paused close test passes with the stall removed, and with no connection at all. So:
shutdown_reports_a_stalled_closedials a real peer and strands the connection's driver on a dropped runtime, then asserts the breach (~2 s wall clock).shutdown_reports_a_live_close_as_cleanis its control: same endpoint, peer and deadline, driver left running, closes in ~0.08 s.Flipping
ConnDriver::Stranded→Livefails the breach test (ShutdownReport { closed: 1, of_endpoints: 1 }). That mutation is what makes the pair coverage of #1675 rather than of tokio's virtual clock.The other half of the breach line is pinned too.
shutdown_reports_a_task_that_outlives_its_abortcoversreapedshort ofN— the reading that names this fixture's own defect rather than #1675. An abort only drops a task's future at its next poll, so a task that never yields never takes it;spawn_blockingparks one on a blocking-pool thread rather than wedging a runtime worker, and a start signal is awaited first to rule out the cancellation path. Swapping it for an abortabletokio::spawn(pending())fails withShutdownReport { reaped: 1, of_tasks: 1 }.3.
dht_integration.rshygieneRemoved changelog voice from the header and renamed
find_providers_negative_cache_expires_after_ttltofind_providers_stops_suppressing_once_the_negative_entry_expires.Known gaps
ShutdownReportis not#[must_use]: it would fire at all 253shutdown(…).await?;sites under-D warnings, and the fix at each is alet _ =that suppresses the lint it adds. Ashutdown_expecting_clean()wrapper for the suites that care is the cheaper ratchet.Verification
cargo nextest run --workspace— 3030/3030 passcargo clippy --workspace --all-targetsclean,cargo fmt --all -- --checkclean,RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-depsclean