From f3533ea83490a5bd09cfb9e66f7f939f1f747c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Tue, 6 Sep 2022 19:51:46 +0300 Subject: [PATCH 1/2] Update DatabaseQueue.php PlanetScale provides great serverless MySQL-compatible database and guide on how to integrate it in Laravel (https://planetscale.com/docs/tutorials/connect-laravel-app) but under hood uses Vitess. However it looks that Vitess doesn't support "skip" queries: ```SQLSTATE[HY000]: General error: 1105 syntax error at position 185 near 'SKIP' (SQL: select * from `jobs` where `queue` = default and ((`reserved_at` is null and `available_at` <= 1662479913) or (`reserved_at` <= 1662479823)) order by `id` asc limit 1 FOR UPDATE SKIP LOCKED)``` Following https://github.com/laravel/framework/issues/31536 I've improved engine/version parsing for Vitess so it wouldn't use locks for popping: ```>>> DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) => "mysql" >>> DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION) => "8.0.23-vitess"``` --- src/Illuminate/Queue/DatabaseQueue.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Illuminate/Queue/DatabaseQueue.php b/src/Illuminate/Queue/DatabaseQueue.php index ede134cdc7cd..d38ed1dd1fe7 100644 --- a/src/Illuminate/Queue/DatabaseQueue.php +++ b/src/Illuminate/Queue/DatabaseQueue.php @@ -261,6 +261,9 @@ protected function getLockForPopping() if (Str::of($databaseVersion)->contains('MariaDB')) { $databaseEngine = 'mariadb'; $databaseVersion = Str::before(Str::after($databaseVersion, '5.5.5-'), '-'); + } else if (Str::of($databaseVersion)->contains('vitess')) { + $databaseEngine = 'vitess'; + $databaseVersion = Str::before($databaseVersion, '-'); } if (($databaseEngine === 'mysql' && version_compare($databaseVersion, '8.0.1', '>=')) || From 267daa3c0806ae84fed4ca0e6a88d10015347725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Tue, 6 Sep 2022 19:56:18 +0300 Subject: [PATCH 2/2] Update DatabaseQueue.php --- src/Illuminate/Queue/DatabaseQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/DatabaseQueue.php b/src/Illuminate/Queue/DatabaseQueue.php index d38ed1dd1fe7..7fb9ff9cbabf 100644 --- a/src/Illuminate/Queue/DatabaseQueue.php +++ b/src/Illuminate/Queue/DatabaseQueue.php @@ -261,7 +261,7 @@ protected function getLockForPopping() if (Str::of($databaseVersion)->contains('MariaDB')) { $databaseEngine = 'mariadb'; $databaseVersion = Str::before(Str::after($databaseVersion, '5.5.5-'), '-'); - } else if (Str::of($databaseVersion)->contains('vitess')) { + } elseif (Str::of($databaseVersion)->contains('vitess')) { $databaseEngine = 'vitess'; $databaseVersion = Str::before($databaseVersion, '-'); }