Skip to content

Explain what to do when a worker process dies - #2762

Open
ndbroadbent wants to merge 1 commit into
Shopify:mainfrom
DocSpring:nathan/dead-worker-message
Open

ndbroadbent wants to merge 1 commit into
Shopify:mainfrom
DocSpring:nathan/dead-worker-message

Conversation

@ndbroadbent

Copy link
Copy Markdown

See #1566.

Motivation

When a forked worker exits without reporting back, Parallel raises Parallel::DeadWorker and Tapioca prints only that error's backtrace, which doesn't say what happened or what to try. (A worker that raises a Ruby exception sends it back, and the parent re-raises it, so DeadWorker means the process was killed or crashed.) The usual causes are running out of memory and a native extension crashing after the fork. On macOS with PostgreSQL the second is common enough that the advice to set PGGSSENCMODE=disable has been given in #1555, #2241 and #2390.

Implementation

Executor#run_in_parallel turns Parallel::DeadWorker into a Tapioca::Error, which exe/tapioca prints without a backtrace:

A worker process exited before it finished. Tapioca forks 2 worker processes, and a worker usually
dies because the system ran out of memory, or because a native extension crashed in the forked process
(look above for a crash report, such as `[BUG] Segmentation fault`).

To do the work in a single process, which shows the error if there is one, run the command again with
`--workers=1`.

On macOS, a crash in the pg gem while it connects to PostgreSQL comes from libpq trying GSSAPI
encryption. Turn it off with `PGGSSENCMODE=disable` in the environment, or with
`gssencmode: disable` in config/database.yml.

The last paragraph appears only on macOS, with the pg gem loaded and PGGSSENCMODE unset. This covers the "at the very least" half of #1566; it doesn't recover the dead worker's own trace, which for a crash Ruby has already printed to stderr above the message.

Tests

Two executor specs: a worker that kills itself gives the message, and the PostgreSQL paragraph appears only when the check says it applies.

When a forked worker exits without reporting back (killed for running out
of memory, or crashed in a native extension), Parallel raises
`Parallel::DeadWorker` and Tapioca printed only its backtrace. Raise a
`Tapioca::Error` instead, saying what usually kills a worker, where to look
for a crash report, and that `--workers=1` runs the work in one process.

On macOS with the pg gem loaded and `PGGSSENCMODE` unset, also suggest
turning off libpq's GSSAPI encryption, which is the fix maintainers have
pointed people to in Shopify#1555, Shopify#2241 and Shopify#2390.

See Shopify#1566.
@ndbroadbent
ndbroadbent requested a review from a team as a code owner November 3, 2026 07:13

This branch has not been deployed

No deployments
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