Skip to content

Commit

Permalink
Merge pull request #391 from dmipeck/bugfix/grabmutex-error-on-sqlite
Browse files Browse the repository at this point in the history
FIX grabMutex job lock query on SQLite
  • Loading branch information
GuySartorelli authored Dec 19, 2023
2 parents 6e0c8df + 7cdce8f commit f3b7abb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Services/QueuedJobService.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ protected function grabMutex(QueuedJobDescriptor $jobDescriptor)
try {
// Start a transaction which will hold until we have a lock on this descriptor.
DB::get_conn()->withTransaction(function () use ($descriptorId) {
$query = 'SELECT "ID" FROM "QueuedJobDescriptor" WHERE "ID" = %s AND "Worker" IS NULL FOR UPDATE';
$forUpdate = DB::getConfig()['type'] == 'SQLite3Database' ? '' : ' FOR UPDATE';
$query = 'SELECT "ID" FROM "QueuedJobDescriptor" WHERE "ID" = %s AND "Worker" IS NULL' . $forUpdate;

$row = DB::query(sprintf($query, Convert::raw2sql($descriptorId)))->first();

Expand Down

0 comments on commit f3b7abb

Please sign in to comment.