sakm wrote: ↑
Wed Nov 04, 2020 6:52 pm
Hi all I keep getting server gone away errors since today but it only seems to be on some certain topics and forums
I've been seeing the same problem; I'm also running MariaDB 10.5.7 and just updated to 10.5.8. That said, while debugging, I noticed that some phpBB query statements have the potential to pass in huge
queries. For example, in include/functions.php:
Code: Select all
// Mark all post/quote notifications read for this user in this forum
$topic_ids = array();
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_id);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
$topic_ids = $row['topic_id'];
), $topic_ids, $user->data['user_id'], $post_time);
Following the code above, you'll find that it generates a DELETE with an unbounded number of topic IDs in phpbb/notification/method/email.php:
Code: Select all
public function mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time = false, $mark_read = true)
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : '1=1') .
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
($item_parent_id !== false ? ' AND ' . $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : '');
This would work fine in a small forum, but what if a forum contained 10s of thousands of topics? I saw the same errors in mark_notifications you reported and suspect they have the same cause. The phpBB code should check for the topic array count and if it's > some threshold, break the DELETE calls into chucks so the database isn't passed a multi-megabyte query statement.