Bug 1568016

Summary: notifications do not get cleared from the notification table
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: ApplianceAssignee: Nick LaMuro <nlamuro>
Status: CLOSED ERRATA QA Contact: luke couzens <lcouzens>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: abellott, cpelland, dmetzger, fdewaley, lcouzens, nlamuro, obarenbo, smallamp
Target Milestone: GAKeywords: ZStream
Target Release: 5.8.4   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: 5.8.4.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1544890 Environment:
Last Closed: 2018-06-25 14:20:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1544890    
Bug Blocks:    

Comment 3 luke couzens 2018-05-17 13:33:19 UTC
Verified in 5.8.4.2

Comment 4 Felix Dewaleyne 2018-06-06 12:45:31 UTC
the customer found that table "notification_recipients" also needs to be cleared. 

[1]
~~~~~~~~~~~~~~
psql -U postgres vmdb_production -c "DELETE FROM notifications n WHERE n.created_at < '$(date -u --date="1 day ago" +"%Y-%m-%d %H:%M")' AND n.notification_type_id IN ( SELECT nt.id FROM notification_types nt WHERE NOT nt.level='warning' AND NOT nt.level='error' );"
~~~~~~~~~~~~~~

if this is correct, how can we clean it?

Comment 5 Nick LaMuro 2018-06-06 15:05:36 UTC
Hmm.... that is odd.  I specifically covered that case in the changes.

You should be able to run the following though (NOT TESTED) and clear out the notification recipients related to the notification records as well:

```
DELETE FROM notification_recipients
WHERE notification_recipients.notification_id NOT IN (
  SELECT id FROM notifications
);
```

Should delete all notification_recipients where the notification_id is now not present in the notifications table (was purged).


* * *

Can you tell me what version this is happening on?  Might be related to the purging mixin code, and some of that extra functionality might have not made it in whatever version they are experiencing it on, so the associated records are not being deleted.

That said, I added tests around this specifically for Notification recipients, so it might be something else.

Comment 10 errata-xmlrpc 2018-06-25 14:20:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:1972