Email_cache table constantly updated

We’re running on 7.8.31 (last version before you were forced to go to SuiteP theme which we hate.) We’ve grown to double the users we had a year ago (10 versus 5). I noticed in the Linux top list the mysql process is taking 97%+ CPU more often than I usually see it. This is also due to a lot of custom external code we’ve added that access the suite DB. However I have periodically been checking the MySQL process list different times of the day and it seems to almost be constantly executing update commands on the email_cache table.

We connect to only one IMAP account inbound email account (hosted on the same server). It is used to store all emails forwarded in that related to various cases. So naturally it has grown, on the SuiteCRM email table side. All emails that come in to Suite from that address are deleted on the email server.

In addition, no one uses the inbox view in the Email module to access the emails associated with the cases. We built a custom Email tab in the Case module to list all the emails for the case. There’s over 1000 email messages in the inbound email account which is all the emails for all the associated cases combined. So the system appears to be basically periodically (probably every time a new email comes in) churning through all the emails in the email table for that inbound account and upated the cache so it’s executing 1000+ update statements.

I would assume if I hacked the code to prevent it from doing that, the list of email in the inbound email account inbox would not be up-to-date which isn’t a big deal as, as I said, we don’t access the emails from tht interface. I’m a little leary about totally disabling it. Maybe ideally, limiting the frequency, such as making it a daily cron even to update the email_cache?

Any suggestions?

On a google search I found a reference that said in the newer versions of suite the email_cache table id deprecated!

I determined the actual problem and solution. For the inbound email account, the option to NOT leave the messages on the server of course moves them to the TRASH folder on the IMAP server. Since this is an account no one actually ever logs into, the TRASH folder has been building up for years, now having over 60K messages. So SuiteCRM goes to update the email_cache table and has to chug through all 60K of those trash folder messages when it does it. (Granted supposed newer versions of Suite the email_cache is deprecated but posting this in case someone like me has chose to fork their own customized version off of a version before it was deprecated.)

The solution (in this example if the IMAP server is Dovecot) is to setup a cron even to run two commands:

rm -fr /home/{username}/mail/{domain name}/{email account}/.Trash/cur/* ; rm -fr /home/{username}/mail/{domain name}/{email account}/.Trash/dovecot.*

I run it once a week. Otherwise the INBOX.trash records in the email_cache table will grow indefinitely unless you login to the mail server and manually delete the messages in the trash folder.

Check the number of records in your email_cache table (if you have one). Remove all the records and see if they all re-appear with messages in mbox INBOX.trash? If so, you have this problem.

1 Like

Yes it changed alot in 7.9 and beyond -