diff options
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 8 |
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(); |
