CleanUpEmailLogs job fails on having a lot of email logs


(eriko) #1

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.


(Jeff Atwood) #2

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?


(RĂ©gis Hanol) #3

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


(Jeff Atwood) #4

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