Skip to content

Queue: throw when a failed job can't be stored instead of only logging it #641

Closed

Description

@markshust

Problem

FailedJobHandler (#535) saves a failed job, calls failed(), then fires JobFailedEvent. If saving the failed job throws, it only logs the problem (through LoggerInterface since #608). A job whose final failure couldn't be recorded is a real error, and under Marko's loud-errors rule it shouldn't be reduced to a log line.

Proposal

When storing the failed job fails, throw a typed QueueException (for example failedJobNotStored) that names the job class and id, with the storage exception as previous. Keep the behaviour from #535: failed() is not called when storing fails, so it never runs twice for one job, and the job stays reserved so it's retried and failed again later. Check how each caller handles the new exception:

  • the worker: it should exit with a clear error rather than keep pulling jobs while storage is broken. Decide and document this.
  • DatabaseQueue::pop() and the sync driver.

Exit criteria

  • Storage failure throws QueueException with the cause attached, and no longer only logs
  • Tests for the worker, database pop-time and sync paths
  • Docs: queue page, failure handling section
  • composer ci green

Follow-up from the #608 logger discussion.

Activity

  1. markshust commented on Nov 1, 2026

    @markshust
    CollaboratorAuthor

    Fixed in #643 (merged).

    When a failed job can't be stored, the queue now throws FailedJobNotStoredException (a QueueException), naming the job and queue and chaining the storage error. failed() and JobFailedEvent still don't run, and the job stays reserved so it's failed again later.

    The worker logs the error at critical and stops: queue:work exits with 1, so it doesn't keep pulling jobs while storage is broken. Inside a job timeout (the alarm handler), it logs and exits with 1 without throwing. The queue docs have a new section on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions