Skip to content

Playground: cover the second class of TAP-busy leak (post-teardown zombies) - #1207

Merged
alexey-milovidov merged 1 commit into
mainfrom
fix-shutdown-reap-and-teardown-tap
Aug 4, 2026
Merged

Playground: cover the second class of TAP-busy leak (post-teardown zombies)#1207
alexey-milovidov merged 1 commit into
mainfrom
fix-shutdown-reap-and-teardown-tap

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

Root cause of the recurring

    FirecrackerError('PUT /snapshot/load -> 400: Resource busy (os error 16).
                     Invalid TUN/TAP Backend provided by fc-tap-<slot>')

was in _teardown, not _restore_snapshot. Evidence: 20 orphaned fc processes on the box, all with 200 MiB..16 GiB RSS — i.e. VMs that successfully restored, ran, and were later kicked (idle-reaper / ensure-failed-retry / post-query-error). Something in _shutdown + _teardown wasn't finishing them off. Two fixes here:

  1. _shutdown: asyncio.wait_for(vm.proc.wait(), timeout=5.0) is too short. Post-SIGKILL cleanup of a 16 GiB guest can take many seconds (page freeing + virtio-blk fd close + memory-backing unmap), especially under concurrent shutdowns. When wait_for timed out, vm.proc/vm.pid were reset but the OS process was still alive holding fc-tap-. Bump the reap window to 60 s and follow up with an explicit _pid_alive poll that re-SIGKILLs on each iteration. Log an error if the process outlives that window (previously silent).

  2. _teardown: also call net.teardown_tap unconditionally. Even in the (now-rare) case a lingering fc still holds the TAP fd, the next /restore's ensure_tap re-creates a fresh TAP. Cheap (single tuntap add + addr), guaranteed clean.

Fixes the "many systems fail with Resource busy fc-tap-" reports across chdb-dataframe, clickhouse, starrocks, polars-dataframe, doris-parquet, heavyai, spark-comet, victorialogs, quickwit, trino-partitioned, clickhouse-web, and others.

…mbies)

Root cause of the recurring
    FirecrackerError('PUT /snapshot/load -> 400: Resource busy (os error 16).
                     Invalid TUN/TAP Backend provided by fc-tap-<slot>')

was in _teardown, not _restore_snapshot. Evidence: 20 orphaned fc
processes on the box, all with 200 MiB..16 GiB RSS — i.e. VMs that
successfully restored, ran, and were later kicked (idle-reaper /
ensure-failed-retry / post-query-error). Something in _shutdown +
_teardown wasn't finishing them off. Two fixes here:

1. _shutdown: `asyncio.wait_for(vm.proc.wait(), timeout=5.0)` is too
   short. Post-SIGKILL cleanup of a 16 GiB guest can take many
   seconds (page freeing + virtio-blk fd close + memory-backing
   unmap), especially under concurrent shutdowns. When wait_for
   timed out, vm.proc/vm.pid were reset but the OS process was
   still alive holding fc-tap-<slot>. Bump the reap window to 60 s
   and follow up with an explicit _pid_alive poll that re-SIGKILLs
   on each iteration. Log an error if the process outlives that
   window (previously silent).

2. _teardown: also call net.teardown_tap unconditionally. Even in
   the (now-rare) case a lingering fc still holds the TAP fd, the
   next /restore's ensure_tap re-creates a fresh TAP. Cheap
   (single tuntap add + addr), guaranteed clean.

Fixes the "many systems fail with Resource busy fc-tap-<N>" reports
across chdb-dataframe, clickhouse, starrocks, polars-dataframe,
doris-parquet, heavyai, spark-comet, victorialogs, quickwit,
trino-partitioned, clickhouse-web, and others.
@alexey-milovidov alexey-milovidov self-assigned this Aug 4, 2026
@alexey-milovidov
alexey-milovidov merged commit 606b42d into main Aug 4, 2026
2 checks passed
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