Detect signaled parallel workers#60
Conversation
|
Warning Review limit reached
More reviews will be available in 56 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds signal-aware worker exit validation for forked build workers so parallel operations fail fast (and with clearer diagnostics) when a worker crashes or is terminated by a signal.
Changes:
- Introduces
WorkerProcessStatus::assertSucceeded()to interpretpcntl_waitpid()status for normal exits vs signaled termination. - Uses the shared status checker in
ParallelTaskRunnerandParallelEntryWriter, including preserving a representative failure as thepreviousexception for entry writes. - Adds unit tests that simulate worker termination via
SIGKILL.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/Build/WorkerProcessStatus.php |
New shared helper to validate worker process termination status (exit code vs signal). |
src/Build/ParallelTaskRunner.php |
Switches worker validation to WorkerProcessStatus instead of pcntl_wexitstatus() only. |
src/Build/ParallelEntryWriter.php |
Uses WorkerProcessStatus and propagates a worker failure via previous exception. |
tests/Unit/Build/ParallelTaskRunnerTest.php |
Adds coverage for failure when a worker is terminated by signal. |
tests/Unit/Build/ParallelEntryWriterTest.php |
Adds coverage for failure when an entry-writing worker is terminated by signal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function testRunFailsWhenWorkerIsTerminatedBySignal(): void | ||
| { | ||
| $runner = new ParallelTaskRunner(); | ||
|
|
| public function testWriteFailsWhenParallelWorkerIsTerminatedBySignal(): void | ||
| { | ||
| $tasks = []; |
| foreach ($pids as $pid) { | ||
| pcntl_waitpid($pid, $status); | ||
| if (pcntl_wexitstatus($status) !== 0) { | ||
| throw new RuntimeException('One or more worker processes failed'); | ||
| } | ||
| WorkerProcessStatus::assertSucceeded($pid, $status); | ||
| } |
| foreach ($pids as $pid) { | ||
| pcntl_waitpid($pid, $status); | ||
| if (pcntl_wexitstatus($status) !== 0) { | ||
| try { | ||
| WorkerProcessStatus::assertSucceeded($pid, $status); | ||
| } catch (RuntimeException $e) { |
| if (function_exists('pcntl_wifexited') && pcntl_wifexited($status)) { | ||
| $exitCode = pcntl_wexitstatus($status); | ||
| if ($exitCode === 0) { | ||
| return; | ||
| } | ||
|
|
||
| throw new RuntimeException(sprintf('Worker process %d exited with code %d.', $pid, $exitCode)); | ||
| } | ||
|
|
||
| if (function_exists('pcntl_wifsignaled') && pcntl_wifsignaled($status)) { | ||
| throw new RuntimeException(sprintf( | ||
| 'Worker process %d was terminated by signal %d.', | ||
| $pid, | ||
| pcntl_wtermsig($status), | ||
| )); | ||
| } |
Summary
Tests