Skip to content

test(fast_io): IOCP disk-full simulation (#1932) - #4238

Merged
oferchen merged 1 commit into
masterfrom
test/iocp-disk-full-1932
May 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/iocp-disk-full-1932

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds crates/fast_io/tests/iocp_disk_full_simulation.rs, cfg-gated to windows + iocp, exercising the IOCP disk-commit path under simulated ERROR_DISK_FULL.
  • Introduces a dormant, #[doc(hidden)] single-shot fault hook in IocpDiskBatch::submit_one_write so the test can deterministically inject Win32 error 112 without provisioning a limited-capacity volume on CI.
  • Verifies that std maps ERROR_DISK_FULL (112) and ERROR_HANDLE_DISK_FULL (39) to io::ErrorKind::StorageFull on Rust 1.88, so the existing transfer-layer fatal-error categorization fires automatically.

Rationale

Real disk-full coverage on Windows would require a VHD or quota-bounded volume per test - heavyweight and flaky on hosted runners. Approach C from the design note (docs/design/iocp-disk-full-tests.md) injects a synthetic Win32 error code at the submit boundary, which delivers byte-for-byte the same error path the kernel would return when the volume is full.

The hook adds a single relaxed AtomicUsize load to the submit hot path and is excluded from the public API surface (#[doc(hidden)] on the module re-export).

Test cases

  1. std_maps_disk_full_codes_to_storage_full_kind - sanity check that std maps both 112 and 39 to StorageFull.
  2. first_submission_disk_full_surfaces_storage_full - flush propagates the injected error with the raw OS code intact.
  3. writer_drop_after_disk_full_is_clean - a previously committed file survives a later fault; Drop runs without panic or port wedge.
  4. batch_recovers_after_injected_fault_consumed - the hook is single-shot; a fresh batch writes through end-to-end.
  5. nth_submission_disk_full_skips_earlier_writes - countdown lets pre-fault chunks reach disk before the Nth submission fails.

Test plan

  • fmt+clippy
  • nextest (stable)
  • Windows (stable) - the new integration test exercises the IOCP path
  • macOS (stable) - file compiles to nothing
  • Linux musl (stable) - file compiles to nothing

Add deterministic disk-full coverage for the Windows IOCP disk-commit
path. Real ERROR_DISK_FULL coverage on CI would require provisioning a
fixed-size VHD or quota-bounded volume per test; both are heavyweight
and flaky on hosted runners. Instead, surface a single-shot fault hook
inside `IocpDiskBatch::submit_one_write` that returns a synthetic Win32
error code before any kernel call.

The hook is dormant by default (a relaxed AtomicUsize load on the
submit path) and exposed as `#[doc(hidden)]` so production callers
never see it. The new integration test
`crates/fast_io/tests/iocp_disk_full_simulation.rs` is cfg-gated to
`windows + iocp`, so it compiles to nothing on Linux and macOS.

Cases covered:
- std maps Win32 ERROR_DISK_FULL (112) and ERROR_HANDLE_DISK_FULL (39)
  onto io::ErrorKind::StorageFull on Rust 1.88.
- First-submission fault during flush surfaces as StorageFull with the
  raw OS error intact, matching what the disk-commit thread reaps from
  a real WriteFile completion.
- commit_file fault leaves a prior successfully-committed file on disk
  intact and lets Drop run cleanly with no panic and no port wedge.
- Hook is single-shot: a second batch after the fault writes through
  end-to-end with no manual reset.
- Nth-submission countdown lets the first two 4 KB chunks reach disk
  before faulting the third, so the file lands at exactly 8 KB.
@github-actions github-actions Bot added the test label May 17, 2026
@oferchen
oferchen merged commit 31ec3bd into master May 17, 2026
38 of 39 checks passed
oferchen added a commit that referenced this pull request May 18, 2026
Add deterministic disk-full coverage for the Windows IOCP disk-commit
path. Real ERROR_DISK_FULL coverage on CI would require provisioning a
fixed-size VHD or quota-bounded volume per test; both are heavyweight
and flaky on hosted runners. Instead, surface a single-shot fault hook
inside `IocpDiskBatch::submit_one_write` that returns a synthetic Win32
error code before any kernel call.

The hook is dormant by default (a relaxed AtomicUsize load on the
submit path) and exposed as `#[doc(hidden)]` so production callers
never see it. The new integration test
`crates/fast_io/tests/iocp_disk_full_simulation.rs` is cfg-gated to
`windows + iocp`, so it compiles to nothing on Linux and macOS.

Cases covered:
- std maps Win32 ERROR_DISK_FULL (112) and ERROR_HANDLE_DISK_FULL (39)
  onto io::ErrorKind::StorageFull on Rust 1.88.
- First-submission fault during flush surfaces as StorageFull with the
  raw OS error intact, matching what the disk-commit thread reaps from
  a real WriteFile completion.
- commit_file fault leaves a prior successfully-committed file on disk
  intact and lets Drop run cleanly with no panic and no port wedge.
- Hook is single-shot: a second batch after the fault writes through
  end-to-end with no manual reset.
- Nth-submission countdown lets the first two 4 KB chunks reach disk
  before faulting the third, so the file lands at exactly 8 KB.
oferchen added a commit that referenced this pull request May 18, 2026
Add deterministic disk-full coverage for the Windows IOCP disk-commit
path. Real ERROR_DISK_FULL coverage on CI would require provisioning a
fixed-size VHD or quota-bounded volume per test; both are heavyweight
and flaky on hosted runners. Instead, surface a single-shot fault hook
inside `IocpDiskBatch::submit_one_write` that returns a synthetic Win32
error code before any kernel call.

The hook is dormant by default (a relaxed AtomicUsize load on the
submit path) and exposed as `#[doc(hidden)]` so production callers
never see it. The new integration test
`crates/fast_io/tests/iocp_disk_full_simulation.rs` is cfg-gated to
`windows + iocp`, so it compiles to nothing on Linux and macOS.

Cases covered:
- std maps Win32 ERROR_DISK_FULL (112) and ERROR_HANDLE_DISK_FULL (39)
  onto io::ErrorKind::StorageFull on Rust 1.88.
- First-submission fault during flush surfaces as StorageFull with the
  raw OS error intact, matching what the disk-commit thread reaps from
  a real WriteFile completion.
- commit_file fault leaves a prior successfully-committed file on disk
  intact and lets Drop run cleanly with no panic and no port wedge.
- Hook is single-shot: a second batch after the fault writes through
  end-to-end with no manual reset.
- Nth-submission countdown lets the first two 4 KB chunks reach disk
  before faulting the third, so the file lands at exactly 8 KB.
@oferchen
oferchen deleted the test/iocp-disk-full-1932 branch May 19, 2026 19:27
oferchen added a commit that referenced this pull request Aug 24, 2026
Add deterministic disk-full coverage for the Windows IOCP disk-commit
path. Real ERROR_DISK_FULL coverage on CI would require provisioning a
fixed-size VHD or quota-bounded volume per test; both are heavyweight
and flaky on hosted runners. Instead, surface a single-shot fault hook
inside `IocpDiskBatch::submit_one_write` that returns a synthetic Win32
error code before any kernel call.

The hook is dormant by default (a relaxed AtomicUsize load on the
submit path) and exposed as `#[doc(hidden)]` so production callers
never see it. The new integration test
`crates/fast_io/tests/iocp_disk_full_simulation.rs` is cfg-gated to
`windows + iocp`, so it compiles to nothing on Linux and macOS.

Cases covered:
- std maps Win32 ERROR_DISK_FULL (112) and ERROR_HANDLE_DISK_FULL (39)
  onto io::ErrorKind::StorageFull on Rust 1.88.
- First-submission fault during flush surfaces as StorageFull with the
  raw OS error intact, matching what the disk-commit thread reaps from
  a real WriteFile completion.
- commit_file fault leaves a prior successfully-committed file on disk
  intact and lets Drop run cleanly with no panic and no port wedge.
- Hook is single-shot: a second batch after the fault writes through
  end-to-end with no manual reset.
- Nth-submission countdown lets the first two 4 KB chunks reach disk
  before faulting the third, so the file lands at exactly 8 KB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant