Confirmed Marking thread as read doesn't use ALLOW_DEADLOCK_RERUN

mattrogowski

Well-known member
Licensed customer
Affected version
2.2, 2.3
The Forum repository wraps the insert query to xf_forum_read in a executeTransaction block with AbstractAdapter::ALLOW_DEADLOCK_RERUN, but the equivalent Thread repository function markThreadReadByUser doesn't. Wondering if there's a reason for this, and if it could be explored that both do it, as we're seeing some deadlock errors on a very active forum and not sure if this may fix it.
 
I've hotfixed this to the site for the time being and it does seem to help.

PHP:
$this->db()->query($query, [
    $newRead,
    $user->user_id,
    $thread->thread_id,
]);

to

PHP:
\XF::db()->executeTransaction(function (\XF\Db\AbstractAdapter $db) use ($query, $newRead, $user, $thread)
{
    $db->query($query, [
        $newRead,
        $user->user_id,
        $thread->thread_id,
    ]);
}, \XF\Db\AbstractAdapter::ALLOW_DEADLOCK_RERUN);
 
Back
Top Bottom