BiologicalRecordsCentre / iRecord

Repository to store and track enhancements, issues and tasks regarding the iRecord website.
http://irecord.org.uk
2 stars 1 forks source link

Species alerts module causing out of memory error when sending notification emails #915

Closed johnvanbreda closed 1 year ago

johnvanbreda commented 4 years ago

The symptom of this problem is that the scheduled tasks run on the warehouse does not get past the notification emails module. There is nothing obvious in the warehouse log, but in the PHP error log I found the following:

[30-Aug-2020 20:22:39 Europe/London] PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 317272056 bytes) in D:\websites\warehouse\modules\notification_emails\plugins\notification_emails.php on line 571

I reconstructed the query used to find data to send as email notifications and ran it, finding that there were 700,000+ notifications to send to a single user from the species alerts module.

After further investigation I found that this was due to an alert being configured for Cyanobacteria in Scotland, where the user had probably accidentally also chosen the UK Master List (UKSI) as a filter for the alert. The way the species alerts module works, this meant that alerts were being sent for all taxa in Scotland, not just Cyanobacteria.

As a temporary fix I

To fix this:

  1. In the species alerts module, the logic allows either a match on taxon meaning ID, external key, or taxon list ID. I would suggest that it's OK to assume that if the species alert has a taxon meaning ID or external key filter, the taxon list ID should be skipped.
  2. In the UI for the species alerts https://www.brc.ac.uk/irecord/species-alert-notifications it's currently easy to make this mistake. I think the UI could either warn if both alert species and species list are selected, or disallow this state completely.
  3. Maybe we should also disallow the selection of UKSI (or any other large list) as an alert list.

Note there is 1 other long standing species alert on the UK Master List but I didn't change this one as I don't think it's caused a problem before.

kitenetter commented 1 year ago

Not aware that any further problems have arisen - closing.