diff options
author | Mario <mario@mariovavti.com> | 2023-03-19 13:55:18 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-03-19 13:55:18 +0000 |
commit | 89285f1408d21091bb80d45b391ddcbe06ba8d0f (patch) | |
tree | b2eb07d9f3d91d77f89a4565a58e6e5231b20c1c /Zotlabs/Lib/QueueWorker.php | |
parent | 0a679e503ef367eda3085c44af103ee53869a94f (diff) | |
parent | 17c0bb2069dcfe35d3febc5bfdb3a7295f15d49c (diff) | |
download | volse-hubzilla-8.2.tar.gz volse-hubzilla-8.2.tar.bz2 volse-hubzilla-8.2.zip |
Merge branch '8.2RC'8.2
Diffstat (limited to 'Zotlabs/Lib/QueueWorker.php')
-rw-r--r-- | Zotlabs/Lib/QueueWorker.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Zotlabs/Lib/QueueWorker.php b/Zotlabs/Lib/QueueWorker.php index fd2ebd7e1..696fb79fc 100644 --- a/Zotlabs/Lib/QueueWorker.php +++ b/Zotlabs/Lib/QueueWorker.php @@ -137,10 +137,26 @@ class QueueWorker { self::$workermaxage = self::$workermaxage > 120 ? self::$workermaxage : 300; } - q("update workerq set workerq_reservationid = null where workerq_reservationid is not null and workerq_processtimeout < %s", + self::qstart(); + + // skip locked is preferred but is not supported by mariadb < 10.6 which is still used a lot - hence make it optional + $sql_quirks = ((get_config('system', 'db_skip_locked_supported')) ? 'SKIP LOCKED' : 'NOWAIT'); + + $r = q("SELECT workerq_id FROM workerq WHERE workerq_reservationid IS NOT NULL AND workerq_processtimeout < %s FOR UPDATE $sql_quirks", db_utcnow() ); + if ($r) { + $ids = ids_to_querystr($r, 'workerq_id'); + $u = dbq("update workerq set workerq_reservationid = null where workerq_id in ($ids)"); + } + + self::qcommit(); + + //q("update workerq set workerq_reservationid = null where workerq_reservationid is not null and workerq_processtimeout < %s", + //db_utcnow() + //); + //usleep(self::$workersleep); $workers = dbq("select count(distinct workerq_reservationid) as total from workerq where workerq_reservationid is not null"); @@ -175,10 +191,10 @@ class QueueWorker { self::qstart(); - // This is probably the better solution but is not supported by mariadb < 10.6 which is still used a lot. - // $work = dbq("SELECT workerq_id FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE SKIP LOCKED;"); + // skip locked is preferred but is not supported by mariadb < 10.6 which is still used a lot - hence make it optional + $sql_quirks = ((get_config('system', 'db_skip_locked_supported')) ? 'SKIP LOCKED' : 'NOWAIT'); - $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE;"); + $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE $sql_quirks"); if (!$work) { self::qcommit(); |