CleanUpEmailLogs job fails on having a lot of email logs

So it looks like CleanUpEmailLogs is a new Job and on at least my instance is failing at there are to many entries to nuke without the 4 gig box running out of memory. I am using the below to clear out old entries 3 days at a time.

1000.downto(SiteSetting.delete_email_logs_after_days)
    .select.with_index { |x, idx| idx % 3 == 0 }
    .each do |n|
       threshold = n.days.ago
       puts threshold
       EmailLog.where(reply_key: nil).where("created_at < ?", threshold).destroy_all ;0
    end

;0 stops the return of destroy_all from being echoed to the terminal.

2 Likes

Hmm this is a @zogstrip jam can you have a look Regis? Perhaps do raw SQL here if the ActiveRecords are ActingUp… seems like a simple delete?

1 Like

Yeah, I used the wrong helper… That should fix the issue :wink:

https://github.com/discourse/discourse/commit/05f0db0a20525a75247a442aebe120d0bfb200b0

4 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.