Skip to content

Commit fc9dc59

Browse files
author
Rihards Ščeredins
authored
[9.x] Don't use locks for queue job popping for PlanetScale's MySQL-compatible Vitess engine (#44027)
* 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 #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"``` * Update DatabaseQueue.php
1 parent 7a2dddc commit fc9dc59

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Illuminate/Queue/DatabaseQueue.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ protected function getLockForPopping()
261261
if (Str::of($databaseVersion)->contains('MariaDB')) {
262262
$databaseEngine = 'mariadb';
263263
$databaseVersion = Str::before(Str::after($databaseVersion, '5.5.5-'), '-');
264+
} elseif (Str::of($databaseVersion)->contains('vitess')) {
265+
$databaseEngine = 'vitess';
266+
$databaseVersion = Str::before($databaseVersion, '-');
264267
}
265268

266269
if (($databaseEngine === 'mysql' && version_compare($databaseVersion, '8.0.1', '>=')) ||

0 commit comments

Comments
 (0)