Skip to content

fix: eliminate port TOCTOU race in daemon integration tests - #2347

Merged
oferchen merged 1 commit into
masterfrom
fix/flaky-daemon-integration-test
Feb 19, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/flaky-daemon-integration-test

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Replace manual port allocation (bind-check-drop-rebind with PID-based ranges) with OS ephemeral port assignment (port 0), eliminating the TOCTOU race where another nextest process could steal the port between drop and daemon bind
  • Add integration_daemon_server binary to the nextest CI retry policy (was only covering package(daemon))

Root cause

nextest runs each test as a separate process. The old allocate_test_port() used PID-based port ranges with an atomic counter, but close PIDs from nextest forks could map to overlapping ranges. The bind-check-drop pattern left a window for port theft.

Test plan

  • All 17 daemon integration tests pass locally
  • cargo clippy clean
  • cargo fmt clean

Replace manual port allocation (bind-check-drop-rebind) with OS
ephemeral port assignment (port 0). The kernel picks a free port and
avoids immediate recycling, minimizing the race window. Also add
integration_daemon_server to the nextest CI retry policy.
@oferchen
oferchen merged commit 425f519 into master Feb 19, 2026
8 checks passed
@oferchen
oferchen deleted the fix/flaky-daemon-integration-test branch February 19, 2026 01:07
@oferchen oferchen added the bug Something isn't working label Feb 19, 2026
oferchen added a commit that referenced this pull request May 1, 2026
fix: eliminate port TOCTOU race in daemon integration tests
oferchen added a commit that referenced this pull request May 5, 2026
fix: eliminate port TOCTOU race in daemon integration tests
oferchen added a commit that referenced this pull request May 18, 2026
Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
oferchen added a commit that referenced this pull request May 18, 2026
Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
oferchen added a commit that referenced this pull request May 18, 2026
…#4393)

Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
oferchen added a commit that referenced this pull request May 18, 2026
…#4393)

Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
oferchen added a commit that referenced this pull request May 18, 2026
…#4393)

Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
oferchen added a commit that referenced this pull request Aug 24, 2026
…#4393)

Cover the SpillPolicy fields whose runtime behaviour is wired today:

- threshold_bytes: spill stays off at exactly the threshold, engages on
  the first byte over, and engages immediately on a zero budget.
- dir: the override path is observed by the buffer, items round-trip
  through it, the directory is created eagerly, the recreate-once
  recovery path fires when the override vanishes pre-spill, and the
  default `None` keeps the spooled backend.

The remaining knobs (reclaim_mode, granularity, compression) are
placeholders for STN-4..7 and have no observable runtime effect yet,
so no tests are emitted for them here.

Tests are hermetic (TempDir per FS test) and live in a new submodule
crates/engine/src/concurrent_delta/spill/tests_per_knob.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant