Code: Select all
public function mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time = false, $mark_read = true)
{
// split item parent ids into chunks to control memory usage on large # of notifs
if($item_parent_id !== false) {
$chunked=array_chunk($item_parent_id,100);
foreach($chunked as $chunk) {
$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', $chunk, false, true) : '');
$this->db->sql_query($sql);
}
}
else {
$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) : '');
$this->db->sql_query($sql);
}
}
Keep in mind that starting a new topic is not "reporting back" - maybe you want to call a moderator to move these posts to your initial topic?
When one is able to do that just thru SQL then the DBMS must be considered broken. Check which version you're running (and if it is indeed MySQL, not MariaDB) to then check if newer versions fix such a potential bug.BaronVonMEowMEOW wrote: ↑Sun Nov 22, 2020 7:52 ama strange issue with mySQL memory being gradually consumed and not reclaimed, resulting in a crash.
...
I have found the query that is causing the problem and can reliably reproduce it.
That's horrible SQL: why are both user ID and item parent ID handed over as strings instead of integers? Implicit type conversion unnecessarily asks for trouble when it could have been done correctly right away. I hope it's at least coming from an extension, not an untouched phpBB installation.BaronVonMEowMEOW wrote: ↑Sun Nov 22, 2020 7:52 amCode: Select all
AND user_id = '64277' AND item_parent_id IN ('1193', '1750'
If the OP is indeed using MariaDB then it seems like it might be related to this (from another topic)
danielgblack wrote: ↑Wed Nov 11, 2020 9:45 pmMariaDB 10.5.8, 10.4.17, 10.3.27, and 10.2.36 is now available that corrects the excessive memory usage by long list of IN parameters that is presumed to be the cause of this error.
Apologies from the MariaDB community.
We wish you a happy upgrade and continued stability.
Either way, that's fine if they want to move it. I started a new thread to make it more clear what the bug was. I think we know the source of the problem now.AmigoJack wrote: ↑Sun Nov 22, 2020 10:44 amKeep in mind that starting a new topic is not "reporting back" - maybe you want to call a moderator to move these posts to [url=viewtopic.php?f=556&
It is bad practice, however it didn't make any difference in the performace of the query. I tested it both ways.
Code: Select all
DELETE FROM phpbb3_notification_emails
WHERE notification_type_id IN (3, 4, 5, 6, 23) AND user_id = '5044' AND item_parent_id IN ('544', '53', '1939', '1938', '81', '1940', '804', '486', '493', '539', '7610')