Skip to content

feat(taskworker): Add opt-in wait for child exit during recycling - #855

Open
jamieQ wants to merge 2 commits into
mainfrom
fix/wait-for-child-exit
Open

jamieQ wants to merge 2 commits into
mainfrom
fix/wait-for-child-exit

Conversation

@jamieQ

@jamieQ jamieQ commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Motivation

Currently the concurrency setting for task workers does not provide a strict cap on the number of activations that may be executing concurrently. In particular, when a child worker requests to exit, it does so asynchronously. Due to the asynchrony, after requesting to exit from its parent, the child worker may still pick up new work. However, once in this state, the parent no longer counts the child toward the concurrency limit. Thus we can effectively have more work "in flight" than one might naively think possible.

This behavior is sort of problematic for the launchpad service. Launchpad processes potentially-large native app binaries & resources, and its tasks use a fair amount of memory. It was provisioned under the assumption that setting concurrency to 2 meant at most 2 apps would be processed on a pod at a time. Due to the implementation details outlined above, however, sometimes more apps would be processed simultaneously, which occasionally seems to have led pods to OOM.

Changes

Add a new wait_for_child_exit configuration option to control child worker process recycling behavior. When this new value is set to true (defaults to false), exiting workers will still count toward the concurrency limit until they exit.

@jamieQ
jamieQ marked this pull request as ready for review November 10, 2026 14:02
@jamieQ
jamieQ requested a review from a team as a code owner November 10, 2026 14:02
@evanh

evanh commented Nov 10, 2026

Copy link
Copy Markdown
Member

One thought: if a child process gets hung for some reason after being shutdown, that process won't ever be replaced. It might be worth adding a new timeout or some failsafe to catch that case.

Count retiring children toward concurrency until they exit and are reaped when
wait_for_child_exit is enabled. Expose the option in both push and pull workers,
preserving the existing default behavior.
Record when child exit permission is granted and emit the oldest exiting
child age in seconds per pool and pod. Report in both recycling modes,
with zero when no children are exiting, so prolonged exits can be monitored
without a hardcoded threshold or termination policy.
@jamieQ
jamieQ force-pushed the fix/wait-for-child-exit branch from 378418f to 9ed5292 Compare November 11, 2026 15:35
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.

2 participants