aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-11-17 13:48:48 +0100
committerGravatar GitHub <noreply@github.com> 2025-11-17 13:48:48 +0100
commitdeb7633c4932d1838cb0a67aebdab5e37aae7206 (patch)
tree0759233d06580ec952d050c064f547a16958db99 /app/Models/EntryDAO.php
parent419a1978b6d8052f88783a4624cd17602422030a (diff)
Change SQL update query (#6957)
* Change SQL update query for MariaDB / MySQL fix https://github.com/FreshRSS/FreshRSS/issues/5707 * No change for SQLite * Fix merge error * Update MySQL version on the model of PostgreSQL Performance to be tested * Fix LEFT JOIN, also for PostgreSQL / SQLite * Fix alias * Reduce MySQL deadlock * Fix compatibility with SQLite * Back to identical SQL for all databases
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 572c9054d..b4f7451c7 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -1679,7 +1679,13 @@ SQL;
}
return $affected;
}
- $sql = 'UPDATE `_entry` SET `lastSeen`=? WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1) . '?)';
+
+ // Reduce MySQL deadlock probability by ensuring consistent lock ordering
+ $orderBy = $this->pdo->dbType() === 'mysql' ? ' ORDER BY id DESC' : '';
+
+ $sql = 'UPDATE `_entry` ' .
+ 'SET `lastSeen`=? WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1) . '?)' .
+ $orderBy;
$stm = $this->pdo->prepare($sql);
if ($mtime <= 0) {
$mtime = time();