mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.02k stars 1.43k forks source link

The failed_jobs insert error #2379

Closed tbryan24 closed 6 months ago

tbryan24 commented 2 years ago

Description:

Steps to reproduce

1.add a job 2.throw exception in job 3.

Expected behaviour

There has error if insert more than one record into failed_jobs table error message : duplicate key error collection: life_moments.failed_jobs index: uuid_1 dup key: { uuid: null }

Actual behaviour

Rewrite log method from MongoFailedJobProvider.php add public function log($connection, $queue, $payload, $exception) { $failed_at = Carbon::now()->getTimestamp();

    $uuid = json_decode($payload, true)['uuid'];//add this ,because uuid is unique

    $exception = (string) $exception;

    $this->getTable()->insert(compact('uuid','connection', 'queue', 'payload', 'failed_at', 'exception'));
}
Logs: Insert log.txt here (if necessary)
playerarm123 commented 1 year ago

I have same problem

GromNaN commented 1 year ago

https://jira.mongodb.org/browse/PHPORM-87

GromNaN commented 6 months ago

Fixed by #2838