Skip to content

Detect signaled parallel workers#60

Open
samdark wants to merge 1 commit into
masterfrom
fix-parallel-worker-signal-failures
Open

Detect signaled parallel workers#60
samdark wants to merge 1 commit into
masterfrom
fix-parallel-worker-signal-failures

Conversation

@samdark

@samdark samdark commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

  • add a shared worker process status checker for forked build workers
  • fail parallel entry writes when a worker exits abnormally or is terminated by signal
  • use the same signal-aware status validation in ParallelTaskRunner

Tests

  • make test -- --filter ParallelEntryWriterTest
  • make test -- --filter ParallelTaskRunnerTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 12, 2026 22:22
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@samdark, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 396517e8-992a-4913-b7ab-47d7dac077cf

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and d6a3049.

📒 Files selected for processing (5)
  • src/Build/ParallelEntryWriter.php
  • src/Build/ParallelTaskRunner.php
  • src/Build/WorkerProcessStatus.php
  • tests/Unit/Build/ParallelEntryWriterTest.php
  • tests/Unit/Build/ParallelTaskRunnerTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-parallel-worker-signal-failures

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 interpret pcntl_waitpid() status for normal exits vs signaled termination.
  • Uses the shared status checker in ParallelTaskRunner and ParallelEntryWriter, including preserving a representative failure as the previous exception 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.

Comment on lines +73 to +76
public function testRunFailsWhenWorkerIsTerminatedBySignal(): void
{
$runner = new ParallelTaskRunner();

Comment on lines +108 to +110
public function testWriteFailsWhenParallelWorkerIsTerminatedBySignal(): void
{
$tasks = [];
Comment on lines 72 to 75
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);
}
Comment on lines 129 to +133
foreach ($pids as $pid) {
pcntl_waitpid($pid, $status);
if (pcntl_wexitstatus($status) !== 0) {
try {
WorkerProcessStatus::assertSucceeded($pid, $status);
} catch (RuntimeException $e) {
Comment on lines +20 to +35
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),
));
}
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