Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Yahav's avatar
Level 3

Queued jobs not marked "done" but are processed.

So, this is a strange one. I have a fairly simple job, gets a user model and deletes it. Granted, the user model has lots of relations and observers but for the sake of the issue i've disabled the observers. Another thing about the user model is that the relationships db tables are set to cascade on delete. Now for the problem itself, I queue the job, and its being picked up by the worker and its showing as Pending both at the cli as well in Laravel Telescope Jobs page, it is never reaching the Done stage. the job itself is processed fully and everything gets deleted but i cannot not wonder whether its an indication of an issue/problem. In laravel-beanstalkd-admin-ui the job is marked as processed btw. Its only happening with this job, all others are marked as Done.

Google didn't find anything like that, anyone has any idea what this might be and whether its an indicator of an actual problem?

Thanks

0 likes
2 replies
LaryAI's avatar
Level 58

It sounds like the job is being processed but not properly marked as "done" in Laravel's queue system. This could be due to a few reasons, such as an exception being thrown during the job's execution that isn't being caught, or the job not properly signaling completion. Here are a few steps you can take to diagnose and potentially resolve the issue:

  1. Check for Exceptions: Ensure that all exceptions are being caught and logged within your job. This can help identify if something is going wrong during the execution that prevents the job from completing successfully.

    public function handle()
    {
        try {
            // Your job logic here
            $user = User::findOrFail($this->userId);
            $user->delete(); // Assuming cascade deletes are configured in the database
        } catch (\Exception $e) {
            \Log::error("Error processing job for user {$this->userId}: " . $e->getMessage());
            throw $e; // Re-throw the exception to make sure it's visible to Laravel's error handler
        }
    }
    
  2. Ensure Job Completion: Make sure that your job explicitly signals that it has completed its task. This can sometimes be an issue with how jobs are structured or how transactions are handled.

  3. Database Transactions: If your user deletion involves complex transactions or multiple database interactions, ensure they are being handled correctly. Mismanaged transactions can cause a job to hang or terminate without proper completion signaling.

    DB::transaction(function () {
        $user = User::findOrFail($this->userId);
        $user->delete();
    });
    
  4. Job Configuration: Review your job's queue configuration settings in config/queue.php. Ensure that the connection and queue are correctly configured and that there are no specific timeout or retry settings that might be affecting this job differently than others.

  5. Laravel Telescope & Logs: Since you mentioned Laravel Telescope, use it to closely monitor the job's lifecycle. Check the logs for any anomalies or errors during the job's processing. Also, ensure that Laravel's logging is configured to capture enough detail during job processing.

  6. Testing in Different Environments: If possible, test the job in a different environment or with a different queue driver (sync, database, etc.) to see if the issue persists. This can help isolate whether the issue is related to the specific queue driver or configuration.

  7. Update Dependencies: Ensure that all related packages and Laravel itself are up to date. Sometimes, bugs in the framework or third-party packages can cause unexpected behavior.

By following these steps, you should be able to diagnose why the job is not being marked as "done" and ensure that it completes properly in the future.

Please or to participate in this conversation.