Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jobs queued with Model Id 0 #45518

Closed
jasontxf opened this issue Jan 5, 2023 · 2 comments
Closed

Jobs queued with Model Id 0 #45518

jasontxf opened this issue Jan 5, 2023 · 2 comments

Comments

@jasontxf
Copy link

jasontxf commented Jan 5, 2023

  • Horizon Version: 5.10.5
  • Laravel Version: 9.43.0
  • PHP Version: 8.1.5
  • Redis Driver & Version: predis/phpredis (How do I check in forge? Not in composer.json) Redis version: 5.0.7
  • Database Driver & Version: mysql 8.0.21

Description:

When queueing jobs with a model, the queued job model id becomes 0 which resulted in the actual queued job not being able to be processed.

Xnapper-2023-01-05-11 48 12

It doesn't happen all the time, but it happened frequently enough to become a problem for me. This happened right after I upgraded Laravel to 9.43.0. Previously it was working 100% of the time

Steps To Reproduce:

I merely queue it the normal way.

app(SendTelegramMessage::class)
    ->dispatch($log);

I have no idea how to troubleshoot further as it's not happening all the time.
Any help/clues will be greatly appreciated. Thanks!

@ankurk91
Copy link
Contributor

ankurk91 commented Jan 5, 2023

What is the schema for App\MessageLog table?
How are you dispatching this job?

Can you share code your for this job? Specially constructor

@jasontxf
Copy link
Author

jasontxf commented Jan 5, 2023

Hello,

Thanks for replying!

Here's the Schema for MessageLog Table

Schema::create('message_logs', function (Blueprint $table) {
			$table->id();
			$table->foreignId('user_id')->nullable()->constrained()->onDelete('cascade');
			$table->string('channel')->index(); 
			$table->string('source')->index(); 
			$table->text('message')->nullable();
			$table->text('referrer')->nullable();
			$table->json('payload')->nullable();
			$table->json('headers')->nullable();
			$table->timestamps();
		});

Just a very typical model.

I dispatched the job using the following code as stated above

app(SendTelegramMessage::class)
    ->dispatch($log);

The constructor for the jobs looks like this

<?php

namespace App\Jobs;

class SendTelegramMessage implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    /**
     * @var TelegramChat
     */
    public $log;
    
    /**
     * Create a new job instance.
     *
     * @param  MessageLog  $log
     */
    public function __construct(MessageLog $log)
    {
        $this->queue = 'message';
        
        $this->log = $log;
    }

}

Hope it helps!

@laravel laravel locked and limited conversation to collaborators Jan 5, 2023
@driesvints driesvints converted this issue into discussion #45521 Jan 5, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants