Skip to content

feat(storage): share physical admission across scanner and heal - #8911

Merged
overtrue merged 68 commits into
mainfrom
overtrue/physical-disk-admission
Oct 30, 2026
Merged

overtrue merged 68 commits into
mainfrom
overtrue/physical-disk-admission

Conversation

@overtrue

@overtrue overtrue commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Related Issues

Part of rustfs/backlog#2881; builds on #8903 (merged). This does not establish a fix for #8377's macOS CPU bursts.

Summary of Changes

  • Scanner and Heal acquire the existing node and physical-device admission before storage locks. Aliases share device capacity, replacement devices get their own owner, and missing or expired discovery defers work. Native dispatch captures its selected devices rather than retaining the whole operation's node quota.
  • Authenticated background requests use receiver policy. Failed preparation and incomplete response bodies earn no completion credit. Namespace-scanner POSTs use an enabled receiver's local policy even without a sender marker; nested requests preserve the signed wire class.
  • Reservations follow actual payload allocations through native reads, reconstruction, HTTP staging, directory/namespace pipes and envelope decoding, including retained slices and overlapping growth. The decoder ignores untrusted allocation hints and preserves existing wire forms. This does not cover every decoded model or total RSS.
  • Scanner, MRF, manager workers and the channel processor retain their actual joins. Successful durable handoff closes ingress before draining; failed handoff keeps consumers available for retry. Replacement executors retain the existing work owner through persistence. Logical task cancellation returns node capacity while the same issued mutation keeps its physical, memory and lease owners; dropping an outside waiter alone does not cancel that work.
  • Resume inspection, the first local Auto format probe and subsequent known-local inventory use the storage-owned controller and a current single-disk plan. Typed deferral excludes the set and its existing recovery snapshot for that tick. Startup discovery keeps its direct path; remote inventory admission and later housekeeping remain open. Read-only inspection earns no repair completion credit.
  • Maintenance retains the same actual join after its original one-second deadline fails. S3, console and optional front-task collectors preserve actual join failures and remaining owners through waiter cancellation; they do not fail fast. Failed or unknown receipts retain markers and reach the final Root error. HTTP/1.1, HTTP/2 executor work and early body-drain work now retain their actual child joins under the listener owner. The original ten-second absolute deadline remains a failure after late completion; TLS reload groups retain the original shared join and issued rounds until retirement, including late success, panic and cancellation. The listener and reloader use the same original ten-second deadline. H3 startup-error cleanup also joins the original outer task; H3 native leaves and optional child scopes still require separate retirement proof.
  • Root returns its real process status and drops its runtime on the startup thread. Capacity shutdown borrows the same owned future through the original one-second deadline and later cleanup. An observation after that deadline remains a timeout even when Tokio returns Ready, preserves the actual join result, and prevents a marker-clear request.

Head: cb97f62380c8bc9ed7aa0a0e9bbbe6241942645f, one stack-depth fix on top of 1ef92a516a5a980a23048b65956ffecece705988, which merges origin/main (589b499e3) into the previous head ba1386a0fc5bea184c4eadc8369c04775f060ce9 (based on #8903 at 040720aa58c810279be3ab2343be8247f13d4cf7). Verification bullets after the main-sync entries predate the sync unless they say otherwise.

Verification

  • Main sync: 5eb301a803b97898dd61141cc0bcc3d4da3fb2b6 merges origin/main into the previous head ba1386a0fc5bea184c4eadc8369c04775f060ce9 (merge 7c779ec7f with 69f8e364b, then a clean CI-only merge 3f893f35c with 589b499e3), followed by two fix commits; no rebase or force-push. Because feat(scanner): share node admission with background heal #8903 was squash-merged, conflicts were resolved with its pre-squash base 040720aa5 as the three-way base, which removed the duplicated feat(scanner): share node admission with background heal #8903 conflicts. Main wins where both sides changed a path; this branch's physical admission, memory reservation and shutdown join changes stay on top.
  • Notable resolutions: Hotpath follows main's 0.30.1 (the fork pin and its source-policy entry are dropped; the code only uses MeasurementGuardSync::new and #[hotpath::measure], unchanged in 0.30.1). write_all_internal keeps owned Bytes and adopts main's coalesced parent creation inside the same blocking job; main's new source-admission metadata layer and pool-meta native recovery write now pass Bytes. Whole-file reads keep the reserved BackgroundBuffer and adopt main's take(len) bound and pre-sizing. The CAS control-file write keeps the mount lease and adds main's commit_allowed check. Scanner node cancellation (feat(scanner): share node admission with background heal #8903) returns the node slot while started native work keeps only its captured physical leaves. The MRF pending-lifecycle wait (fix(heal): gate unresolved MRF lifecycle writes on reader support #8918) also observes the consumer stop token and finalizes on closed channels. Replacement heal keeps heal_object_with_task_cancel inside main's retry loop (fix(heal): pace and parallelize replacement recovery #9005).
  • Also fixed on this head: guard violations already present on ba1386a0f (the e2e lock-diagnostics filter moved into the e2e storage compatibility module, the namespace memory test reuses the parent module's s3s aliases, and one shared Reed-Solomon verify error mapping restores the ::other(format! baseline) plus Clippy 1.99 findings, without suppressions or baseline changes.
  • Boundaries rechecked: node scheduling quota is not passed into physical I/O scopes (only capture_native leaves are scoped and the node permit is dropped on cancellation); buffers that leave a scope keep their own memory reservation; the scanner bucket-cache coordinator drops its lease before any node or physical wait and revalidates revisions afterwards; scanner-side heal only enqueues for an admission receipt, so inline heal does not wait on the node quota the scanner holds.
  • Local checks on 5eb301a80 (macOS, Rust 1.99.0, debug): cargo fmt --all --check and git diff --check pass; cargo clippy -p rustfs-concurrency -p rustfs-ecstore -p rustfs-scanner -p rustfs-heal -p rustfs-rio -p rustfs-data-usage -p rustfs -p e2e_test --all-targets --locked -- -D warnings exits 0; the unsafe, architecture-migration, logging, error-ratchet, tokio-io-uring, body-cache, s3s-footprint, FIPS-wording, embedded-secrets, doc-path and planning-doc guards exit 0; test_scanner_abba.py 35 passed and the scanner validation harness exits 0.
  • cargo nextest run --profile ci --locked --no-tests fail --lib: concurrency 87/87, data-usage 57/57, rio 218/218, scanner 1249/1249, ecstore with --features test-util filtered to disk::, erasure::coding, io_support::bitrot, core::pool_meta_recovery_codec and set_disk::ops::heal 1344/1344, rustfs filtered to background admission, startup, node/HTTP RPC and server HTTP 404/407, heal 984/997 (one existing ignored W13 evidence test not run).
  • Stack depth (previously the open failure; fixed for the 13 heal tests, the 3 rustfs fixtures await CI): after the sync, 16 tests (13 heal task, resume-handoff, manager and MRF partial-write fixtures; 3 rustfs node_service RPC fixtures) overflowed libtest's default 2 MiB test stack. A frame-pointer walk at the overflow (a temporary local SIGSEGV probe, not committed) showed the four heal fixture families share one chain: LocalDiskWrapper::delete -> track_cleanup_mutation -> track_disk_health_with_op_timeout_action_and_mutation -> ..._with_io_permit -> with_native_resources -> track_admitted_disk_operation, each a 160-280 KiB unoptimized frame (about 1.3 MiB together). Every layer embedded the LocalDisk operation future, and debug builds copy it into each awaiting frame; the last three layers are this PR's admission split. cb97f6238 boxes that future once where track_admitted_disk_operation creates it, through a non-async helper (boxed_disk_operation) so the temporary does not stay in a polled frame. No stack size, nextest setup script, test or allowance changed. Minimum passing RUST_MIN_STACK (64 KiB bisection, debug, macOS) went from 2112-2368 KiB to 768-1152 KiB for 12 of the 13 heal tests. The MRF partial-write test went from 2624 to 1920 KiB: its remaining depth is main's unchanged delete_bucket -> put_object chain, and on main 589b499e3 one of these 13 tests already failed at 1.75 MiB.
  • Open interaction for the owner: while fix(heal): gate unresolved MRF lifecycle writes on reader support #8918's pending lifecycle transition is set, flush() delegates to flush_pending_lifecycle, which can keep returning false (for example when the pending record is no longer active). finalize_mrf_consumer retries failed flushes until one succeeds, so a stop during that state waits for Root's absolute shutdown deadline. The new stop arm does not change this (the loop-top check reaches the same finalize); it was not changed here.
  • Box cost: the allocation is on the per-operation path of every LocalDiskWrapper call routed through track_admitted_disk_operation, so there is one allocation per local disk operation, not per shard dispatch or byte. A standalone release micro-benchmark (macOS system allocator; production uses mimalloc) measured +25-60 ns per boxed future of 0.5-8 KiB and +125-250 ns at 32 KiB. Each of these operations already dispatches to the blocking pool and performs filesystem syscalls, which take microseconds or more. Release-build future sizes and release stack headroom (1 MiB Linux workers) were not measured: the host volume was below 1% free, too little for a release build.
  • Checks on cb97f6238 (macOS, Rust 1.99.0, debug, default stack, cargo nextest run --profile ci --locked --no-tests fail --lib): the 13 former heal overflows 13/13; full heal lib 997/997 (1 skipped: the existing ignored W13 test); scanner + concurrency 1335/1336. The single scanner failure, usage_expiration::lifecycle_expiration_usage_converges_across_complete_scans, returns DiskFull because the host volume had less than the 1% free that DISK_FILL_FRACTION requires. It fails the same way in isolation, is independent of this change, and passed on 5eb301a80. cargo clippy -p rustfs-ecstore --all-targets --features test-util --locked -- -D warnings (test-util matches the workspace feature set; without it, main's fix(rebalance): reuse the target pool holding a dangling copy #9018 PoolSpaceForTest re-export is unused), cargo fmt --all --check, git diff --check and the same 11 guards pass. Not run locally: the 3 rustfs node_service RPC fixtures, because building the rustfs test library needs several GB and its fixtures hit the same DiskFull threshold. They reach the same LocalDiskWrapper funnel and are left to CI.
  • 1ef92a516 only renames the reversed-group variables in two permit_set tests after the PR Typos check flagged ba; on it, typos, cargo fmt --all --check, cargo clippy -p rustfs-concurrency --all-targets -- -D warnings and the concurrency lib tests (87/87) pass. The other sync checks above ran on 5eb301a80, whose non-test code is identical.
  • Not run locally: the workflow wiring checks (check_test_wiring.py, ci_gate.py --check-workflow) need PyYAML, which is not installed; no cluster/e2e runs, G-EXP/G-REB/G-DEC topology gates, ABBA or performance runs on this shared machine. Main has since gained fix: preserve PUT lock failure diagnostics #9062 (PUT lock diagnostics), which merges cleanly and was not tested here.
  • Multipart diagnostics: the original Complete future is now observed while waiting for the strict fault barrier, so an early SDK failure retains its error code and request ID. Every path discards proxy state and joins that same client task; completion after the original deadline stays a timeout. Six actual component cases passed; the unchanged original helper failed the intended late-Ready assertion with ordinary exit 101 after cleanup, and its healthy control passed. The complete e2e_test package passed cargo check -p e2e_test --tests --offline --locked with its original lock and actual default test target. No cluster test ran in that local gate. Only the metadata-delay case enables the existing targeted lock diagnostics before its four nodes start; these logs are not proof of unlock ACKs. The underlying 503 remains unresolved.
  • Latest TLS batch: 39 exact tests plus the 31-name catalog passed on each of macOS and non-root Linux/XFS. Three additional cases passed on each platform with HTTP/3 enabled: two startup-error cleanup cases and TCP certificate rotation. Actual default and HTTP/3 test libraries and non-test libraries built successfully from the same final source, with stable source/dependency/executable identities and no skipped or ignored cases. Commands included cargo test --offline --locked --lib --no-run -p rustfs --features rustfs/e2e-test-hooks and the corresponding HTTP/3 and Linux/musl builds. These are debug, scoped checks; they do not establish live QUIC/native retirement or SSD performance.
  • Published predecessor 17ce7097c41511618ca13ac2249527d201c719a0 passed all 73 selected distributed tests and both upgrade compatibility jobs. The earlier metadata-fault 503 remains a recorded failure with an unresolved cause; a later green run does not establish a fix. This diagnostic change preserves the original five-, twenty- and forty-five-second budgets, fault and quorum assertions, and single SDK attempt.
  • Latest HTTP batch: 37 exact Root tests and four early-startup processes passed on each of macOS and non-root Linux/XFS, without skipped or ignored cases. Actual H2 connection, executor and early body-drain tasks remain owned through release; typed join failures and the original deadline reach Root. Both actual normal binaries were rebuilt from the same final source; committed blobs match that source. These remain debug tests and early hooks, not full service/native retirement or release-performance evidence. Focused bypass controls for the new HTTP scope remain unrun.
  • The preceding published head 1fbda624c90588a687974d22eecda9a84e409a54 failed the distributed multipart metadata-fault case: Complete returned a real namespace-lock timeout 503 before the selected Rename fault was reached. Both upgrade compatibility checks passed. The lock failure remains unresolved; this HTTP change does not establish a fix.
  • Final batch: 65 exact tests (37 Heal and 28 Root) and four early-startup processes passed on each of macOS and non-root Linux/XFS, with no skipped/ignored cases and stable source, executable and dependency identities. Commands included cargo test --offline --locked --lib --no-run -p rustfs-heal -p rustfs --features rustfs/e2e-test-hooks and cargo-zigbuild test --offline --locked --lib --no-run -p rustfs-heal -p rustfs --target x86_64-unknown-linux-musl --features rustfs/e2e-test-hooks. Actual rustfs and rustfs-cli binaries returned the expected success/error codes. These are debug builds and early hooks, not post-storage shutdown or matched-release SSD proof.
  • Complete Heal-crate fault controls detect bypassed inventory admission and lost replacement-worker ownership at the original assertions, with ordinary exit101 and strict source/dependency/cleanup guards. The outside control also verifies the actual native write; it does not pass its later continuation or positive stop assertions. The earlier node-retention control remains a failure at the original node-yield assertion after native release and the same stop join. Format fixtures keep the ordinary three-second samples and original bounds; deliberately damaged formats require the original backend error while the same persisted intent bytes remain intact.
  • An exact-source Root component reproduced late completion producing success and a marker-clear request because Tokio polls Ready before its timer. The same schedule now returns TimedOut, requests no marker clear and joins the real task. The new actual Root module test covers late success and late panic with the original JoinError identity. Other component services are stubs; this is not full service retirement proof.
  • Preceding unchanged batches include envelope decoding, raw-frame staging, actual MRF/channel joins, manager scheduling, resume admission and replacement persistence tests on both platforms, with their source-specific receipts and failing bypass controls retained. Optimized 2 MiB envelope component samples measured about 10.9% more CPU and 14.3% more requested bytes; these costs are not a service result.
  • Before the main sync, the then-pinned Hotpath fork passed 13 isolated functional cases and minimal off/timing/alloc/alloc+prom compilation checks. Source-policy checks passed with the committed configuration. Formatting, architecture-boundary and logging guards passed. Full Root profiling and the remaining SSD gates below were not established by these checks.

Impact

Adaptive admission remains off by default; this PR stays draft. Enable it only when every peer supports the signed background marker. Older peers and disabled receivers reject marked requests. Foreground signatures, placement, quorum and storage/wire formats are preserved. Device admission is not an OS bandwidth limit.

The io_uring completion-owner API is fixed to eb8fc160e71d804427de1e905f5c226d580f71bf from rustfs/uring#20. Hotpath now follows main's crates.io 0.30.1; the earlier RustFS fork pin and its Git source-policy entry were dropped in the main sync, so only the uring repository is added to the Git source policy. A prefix receipt is not a producer-quiescence certificate.

Open gates include decoded/cache models, other RPC serializers, transport/allocator overhead and RSS; later Auto readiness/intent migration, terminal-receipt GC, cross-set bucket metadata and retirement records; gRPC bucket receiver ownership and retryable quota round trips; the real page/nonempty-lease chain; all Root ingress/native/source retirement and ordered profiling drain. Default and legacy paths remain available. Resume GC may defer its first cold-start tick before sampling; its hourly cadence is unchanged.

Same-bucket cold/hot attribution, clone bytes, common multi-node windows, exact client percentiles, matched release builds, oracle/fault/MRF/mixed-version/hot-shrink, the complete SSD matrix and 72-hour soak remain unverified. The earlier short ABBA's 503s and 24.51% p99 drift remain failures. HDD and Windows runtime are unverified.

Additional Notes

Scoped independent reviews covered correctness/concurrency, security/compatibility and simplicity/performance. They do not replace the open service and resource-ownership gates above.

Rollback: revert the change. Adaptive admission can also be disabled on all peers; the shutdown fixes apply independently. No data migration is needed.

@github-actions

Copy link
Copy Markdown
Contributor

CLA requirements are satisfied for this pull request.

@overtrue overtrue changed the title feat(concurrency): retain resource subsets through native I/O feat(concurrency): admit and retain physical resource groups Oct 24, 2026
@overtrue overtrue changed the title feat(concurrency): admit and retain physical resource groups feat(scanner): gate background reads by physical device Oct 25, 2026
@overtrue
overtrue force-pushed the overtrue/scanner-node-feedback branch from 1743834 to b2006b7 Compare October 25, 2026 03:43
@overtrue
overtrue force-pushed the overtrue/physical-disk-admission branch from 24513d9 to 23c62f5 Compare October 25, 2026 03:50
@overtrue overtrue changed the title feat(scanner): gate background reads by physical device feat(storage): share physical admission across scanner and heal Oct 25, 2026
Base automatically changed from overtrue/scanner-node-feedback to main October 28, 2026 03:57
@overtrue
overtrue dismissed houseme’s stale review October 28, 2026 03:57

The base branch was changed.

Merge origin/main 69f8e36. Conflicts were resolved against the
squash-merged node admission (#8903) by using its pre-squash head as
the review base. Main behavior wins where both sides changed the same
path; the physical admission, memory reservation and shutdown join
changes from this branch are kept on top.

- hotpath follows main's 0.30.1 release; the fork pin is dropped.
- write_all_internal keeps owned Bytes and adopts main's coalesced
  parent creation inside the same blocking job.
- The MRF pending-lifecycle wait also observes the consumer stop token.
- Scanner node cancellation returns the node slot while started native
  work keeps only its captured physical leaves.
Merge origin/main 589b499 (CI-only workflow and test-contract update).
Route the multipart lock diagnostics filter through the e2e storage
compatibility module, reuse the parent module's s3s body aliases in the
namespace memory test, and share one Reed-Solomon verify error mapping
across the reserved-buffer and default paths.
Main added a source-admission metadata write layer, a CAS write fence,
fixture writers and scanner handoff tests against the old borrowed-slice
and node-permit shapes. Pass owned Bytes through the new metadata layer,
answer the scanner handoff with ScannerNodePermit, gate the test-only
disk lookup re-export, and clear the lint findings that stable 1.99
reports for the shutdown and admission code without suppressions.
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

  • crates/ecstore/Cargo.toml

Every LocalDiskWrapper operation reaches the LocalDisk future through the
health, admission and timeout layers (track_cleanup_mutation, the
track_disk_health family, the io-permit and native-resource admission
split, and track_admitted_disk_operation). Each layer embedded that future,
and unoptimized builds copy it into every awaiting frame, so one local
delete cost about 1.3 MiB of stack and 16 tests overflowed libtest's
default 2 MiB stack.

Box the operation future once where track_admitted_disk_operation creates
it, through a non-async helper so the temporary never stays in a polled
frame. The layers above now hold only a pointer; the cost is one
allocation per local disk operation.
The admission wrappers took the object heal future by value, so unoptimized
builds copied it into three awaiting frames, about 650 KiB per heal. Create
it through a non-async helper instead, leaving only a pointer in those frames.
@overtrue
overtrue marked this pull request as ready for review October 30, 2026 15:24
…mission

# Conflicts:
#	crates/ecstore/src/disk/local.rs
#	crates/ecstore/src/disk/os.rs
@overtrue
overtrue merged commit 0e5fe8c into main Oct 30, 2026
7 of 9 checks passed
@overtrue
overtrue deleted the overtrue/physical-disk-admission branch October 30, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants