From 7cdce8f678f9443e1fc13450a333bb87b6da9c3a Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Wed, 5 Oct 2022 09:47:16 +1300 Subject: [PATCH] FIX grabMutex job lock query on SQLite --- src/Services/QueuedJobService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/QueuedJobService.php b/src/Services/QueuedJobService.php index b2635d62..023567f6 100644 --- a/src/Services/QueuedJobService.php +++ b/src/Services/QueuedJobService.php @@ -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();