-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
- Laravel Version: 8.61.0
- PHP Version: 7.4.16
- Database Driver & Version: MySQL 5.7
Description:
Can't dispatch jobs into queue (database driver) with a delay of milliseconds. Dispatching with minutes or seconds delay works just fine as expected but milliseconds delay doesn't work. I came to conclusion that it is a limitation of unix timestamp. available_at column in the queue table is a integer column which is filled with unix timestamp values. And unix timestamp is:
It is the number of seconds that have elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970
So it cannot differentiate in milliseconds. Is there a solution to this ?
Steps To Reproduce:
- Migration
Schema::connection('queues')->create('my_jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
- Dispatched job class is not relevant
- Dispatch code:
MyJob::dispatch($jobSpecs)->delay(now()->addMilliseconds(1000)); //available_at column value is incremented by 1 compared to now()
MyJob::dispatch($jobSpecs)->delay(now()->addMilliseconds(100)); //no difference in available_at column in the DB
Metadata
Metadata
Assignees
Labels
No labels