Skip to content

Truncate failure_message so a large failure cannot crash the worker#508

Merged
dereuromark merged 2 commits into
masterfrom
fix/markjobfailed-truncate-failure-message
Jun 6, 2026
Merged

Truncate failure_message so a large failure cannot crash the worker#508
dereuromark merged 2 commits into
masterfrom
fix/markjobfailed-truncate-failure-message

Conversation

@dereuromark

Copy link
Copy Markdown
Owner

Problem

QueuedJobsTable::markJobFailed() persisted the failure message (and captured output) verbatim into the failure_message / output TEXT columns. A failure larger than the column - for example a database QueryException whose message echoes a huge multi-row INSERT with all of its JSON values - made the save() itself throw SQLSTATE[22001]: Data too long for column 'failure_message'.

That means the worker crashes while recording a job failure: the job is left fetched-but-not-completed, the worker process dies, and (with stale queue_processes slots) new workers can be blocked - the queue stalls instead of cleanly failing the one job.

Fix

Byte-truncate failure_message and output to the column size (mb_strcut, multibyte-safe) before saving, via a new FAILURE_MESSAGE_MAX_LENGTH constant (default 65535, the TEXT limit). Recording a failure can no longer overflow the column, so the worker fails the job cleanly and keeps running.

No schema change required.

Notes

  • FAILURE_MESSAGE_MAX_LENGTH is public const, so an app that widened the column can override it.
  • Added testMarkJobFailedTruncatesOversizedMessage.

…e worker

markJobFailed() stored the failure message and captured output verbatim into the
failure_message / output TEXT columns. A failure larger than the column (e.g. a
database error that echoes a huge multi-row query) made the save throw, so the
worker crashed while recording the failure: the job got stuck and the queue
stalled. Byte-truncate both fields to the column size before saving.
A newer phpstan no longer reports an error on the dynamic $this->$action() call,
so the @phpstan-ignore-next-line became an unmatched (failing) ignore. Cast the
result to int to satisfy the declared return type without an ignore.
@dereuromark dereuromark merged commit 64fe313 into master Jun 6, 2026
16 checks passed
@dereuromark dereuromark deleted the fix/markjobfailed-truncate-failure-message branch June 6, 2026 16:09
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