Skip to content

Keep daemon services recoverable under chaos and pool pressure - #198

Merged
reiase merged 2 commits into
mainfrom
reiase/daemon-chaos-recovery
Nov 24, 2026
Merged

reiase merged 2 commits into
mainfrom
reiase/daemon-chaos-recovery

Conversation

@reiase

@reiase reiase commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

What failed

With two 256 MiB native OpenSandbox VMs sharing physical pages and holding memory at the top of an allocation burst, limiting only the pool process's file descriptors caused accept() to return EMFILE. The old pool exited, turning admission pressure into loss of RAM ownership for dependent VMs. The same fault reproduces in a deterministic real-process regression without KVM.

Changes

  • Back off on transient listener resource exhaustion without dropping live pool sessions. Reserve admission slots with RAII and use fallible worker creation so thread exhaustion rejects new admissions instead of panicking the owner.
  • Retry interrupted sandbox lifecycle observations without replaying create/pause/resume. Keep reservations until confirmed cleanup and surface an uncertain registry write as a supervised service stop.
  • Release capacity when a template fails before any native state exists for an unused ID. Bodyless authenticated control requests no longer contend with incomplete bodies for buffering slots.
  • Add real-process coverage of pool FD exhaustion, registry write failure, API SIGKILL at body-buffer saturation, and corrupted-header refusal followed by same-state recovery.

Validation

  • mise run test -- pvisor-daemon: 292 passed, 6 skipped by default.
  • physical_pool_survives_accept_fd_exhaustion: failed before the fix with Too many open files; 30/30 stress iterations passed after it with retries disabled.
  • Delegated Linux/KVM recovery_chaos: 10/10 iterations passed (no guest boot required).
  • Native OpenSandbox comparison: pre-fix pool exited under forced FD exhaustion. Post-fix, the same pool, both VM Executions, and the resident-memory jobs survived. New admission recovered and both guests passed byte checks across API SIGKILL. A follow-up run filled the physical pool to rejection; guest reads and commands remained available, and the test released every synthetic reference.
  • Targeted Clippy, formatting, daemon doctests and rustdoc with warnings denied, and cargo check --locked -p pvisor-cli passed.

This does not make actual physical-pool death recoverable: killing the owner still terminates dependent VMs; cleanup remains available and startup refuses to replace stale pool ownership. Native sealed-compression refault after pool death was not exercised on this host (kernel-fault userfaultfd is not permitted). The longer native soak is separate from these completed checks.

@reiase

reiase commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Native physical-pool soak: passed

The fixed build completed 167/167 two-VM rounds in 30m 9s, with no harness retries. All rounds observed shared backing, recovered new pool admissions after both descriptor and thread exhaustion, and preserved both VM Executions and their jobs across an API SIGKILL. There were 6,680 verified memory pressure waves, 56 pool-budget saturation/release cycles, and zero guest OOM kills (maximum observed guest cgroup peak: 241.4 MiB out of 256 MiB).

Each round also deliberately killed the physical pool. Both VM runner processes exited every time; inspection returned Terminated for 310 sandboxes and failed closed with 503/RUNTIME_UNAVAILABLE for 24. All 334 deletes returned 204 and the driver confirmed removal of their cgroups. Restart refused to replace stale pool ownership in all 167 rounds.

This validates bounded physical-pool pressure and cleanup, not live VM recovery after physical-pool death, host power loss, or native compressed userfaultfd recovery. The separate six-hour general daemon soak is still in progress and runs without a memory pool.

@reiase
reiase merged commit 59e1387 into main Nov 24, 2026
112 of 115 checks passed
@reiase
reiase deleted the reiase/daemon-chaos-recovery branch November 24, 2026 00:02
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.

1 participant