Skip to content

Laravel 8/MongoDB - job->release() leads to Call to a member function beginTransaction() on null error #2228

Closed
@sodoardi

Description

@sodoardi
  • Laravel-mongodb Version: 3.8.3
  • Laravel-framework: 8.34.0
  • PHP Version: 7.3.26
  • Database Driver & Version:

Description:

Steps to reproduce

  1. Create & dispatch a Job using MongoDB as queue driver
  2. Call $this->release() in the job
  3. Exception: job->release() leads to "Call to a member function beginTransaction() on null" error

Expected behaviour

Job should be pushed back onto the queue with count of attempts += 1

Actual behaviour

Exception: Call to a member function beginTransaction() on null

Cause

In Laravel 8 the Illuminate\Queue\DatabaseQueue class was updated with changed functionality. Instead of calling $database->release() it nows calls a new method $database->deleteAndRelease() which wraps the delete & release operations into a transaction, I'll try to add a PR later which fixes this in Jenssegers\Mongodb\Queue\MongoQueue by adding an overwrite (like it is already done for deleteReserved() and pop() methods of the DatabaseQueue):

public function deleteAndRelease($queue, $job, $delay)
{
  $this->deleteReserved($queue, $job->getJobId());
  $this->release($queue, $job->getJobRecord(), $delay);
}
Logs: Insert log.txt here (if necessary)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions