Repository navigation
Clean adopted children after Pipecat recorder groups exit - #1011
Merged
Merged
Conversation
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #1010
Changelog category (leave one):
Changelog entry
Not required.
Why
The optional Pipecat recorder reports remaining direct children after its owned process groups finish cleanup. A child can leave its launcher's process group while remaining a descendant of the recorder. Group cleanup alone cannot reap that adopted child.
After all four existing cleanup calls succeed, clean direct children adopted by the recorder's active subreaper. Pin each child with a PID file descriptor and verify its parent, birth and UID before signaling or reaping. A changed identity or unavailable ownership check refuses cleanup. There is no numeric-PID signaling fallback.
Scope and risk
Each additional TERM and KILL stage has a shared three-second deadline across all adopted children. These stages add at most six seconds of cleanup waiting; procfs checks are bounded observations, not forcibly interrupted system calls. The current list is limited to 4,096 bytes and 128 children, with at most 128 distinct child identities across both stages. Newly adopted children in the KILL stage receive KILL. Zombies use nonblocking reaping. Every pinned handle is closed, including when another close fails. The existing final census remains separate evidence.
Capture diagnostics gain fixed I/O categories and a bounded numeric errno. They unwrap only an exception-valued URL error reason. An owned launcher snapshot records running, exited, signalled or unavailable with a bounded numeric code, using nonblocking
WNOWAITbefore cleanup. Raw exceptions, browser logs, arguments, URLs, paths and environment values are not exported.Browser environment, sandbox, request deadlines, native assertions, fixture hashes, media limits and workflow caps retain their existing behavior. The browser-session I/O cause remains unknown. This change repairs the owned-child cleanup gap and adds evidence for that separate setup failure.
Compatibility, rollout and rollback
capture_failurewithioanddriver_exitdiagnostics.Tests
The adopted-child regression failed against the original recorder: its final census remained nonempty. The related mocked module passed all 67 cases in 0.94 seconds. Added cases cover TERM-to-KILL escalation, adoption during KILL, changing process groups, zombies, changed parent/birth/UID, PID reuse, the cumulative child bound, unsupported PID descriptors, closing all handles after one close fails, filtered I/O diagnostics and the launcher's unreaped exit snapshot. Ordinary main tests mock the adopted-child sweep; controlled sweep cases enable it only after mocking every process syscall. A fixture-isolation regression failed before the correction because an ordinary main test opened a child descriptor. It passes after the correction and asserts no descriptor open, signal or reap reaches another test's helper. These tests start no browser, product service, database or provider.
Scoped Ruff formatting, lint and the diff whitespace check passed. A local attempt refused admission before workload; a later attempt exposed a test mock that counted a temporary-directory handle as the pinned child handle. Both results remain recorded. The corrected mock passes through ordinary closes and checks the exact pinned handle.
All three actual recording attempts passed the native text memory case and removed their owned database fixture. None produced a qualified video. The latest failed at browser-session setup and reported remaining children after group cleanup; their liveness and exact identity were not exported. Required hosted CI and a fresh independent review of this pushed head passed. A later qualified recording remains outstanding.
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: Codex wrote the change. Source inspection covers process ownership, descriptor lifetime, fixed cleanup deadlines, diagnostic exports and unchanged browser and media controls. Validation is listed above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist