Inbox display is unstable on first Mail launch

(Without using it for a while)
Open the Nextcloud mail application. Then it automatically displays the inbox. An abnormality occurs at this time.
Especially for accounts with a large amount of mail stored on the mail server, it seems easy to encounter this problem. That problem is “Could not load the inbox :-(”.

I reload in the browser several times, or try clicking the “inbox” link on the menu several times, the inbox is displayed.

When I was able to display the inbox even once, I can display the inbox without problems for a while. Even if I change the terminal or Web browser that accesses Nextcloud, it is the same. If I don’t use Mail for a while, I can’t display the inbox again.

When I looked at the error log I learned that MySQL caused an error. It probably thought that “max_allowed_packet” was a problem.
The lower the setting value of this item, the lower the improvement rate. I deliberately set it like a 100M, big. In my case, I found that this problem is not affected around this setting value exceeding 32MB. When I set it to 32MB, I can display the inbox with one reload (or one click the inbox). Even if I set the setting value large(>32MB), it didn’t improve.

Although it is not a fatal problem, is there a way to improve it?


CentOS 7.3, nginx 1.11.13, PHP 7.1.11, MariaDB 5.5.56

error log:

Error	Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `id`, `numeric_id`, `available`, `last_checked` FROM `oc_storages` WHERE `id` IN (?)' with params ["local::\/var\/www\/vhosts\/NEXTCLOUD\/data\/"]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
Error	Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `id`, `uri`, `displayname`, `principaluri`, `description`, `synctoken` FROM `oc_addressbooks` WHERE `principaluri` = ?' with params ["principals\/users\/USERNAME"]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
Error	Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `id`, `uri`, `displayname`, `principaluri`, `description`, `synctoken` FROM `oc_addressbooks` WHERE `principaluri` = ?' with params ["principals\/users\/USERNAME"]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
Error	Error while sending QUERY packet. PID=24113 at /var/www/vhosts/NEXTCLOUD/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#91

Unlike the above error, the following errors occurred several times during these three days.

Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘SELECT uid, displayname FROM oc_users WHERE LOWER(uid) = LOWER(?)’ with params [“USERNAME”]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Apparently this seems to be different for each user, MySQL items have problems.
Is this a MySQL configuration issue? Or is it a problem with the Mail application side?

Is this a problem with MySQL? I’m attempting to tune MySQL whenever possible, but there is not any change at all.
Basically the most likely situation is a mail account with a large amount of mail.
*However, rare occasions occurred even with accounts with a small amount of mail volume. Perhaps this is close to chance.

Does my MySQL adjustment make misplaced adjustments?
Which MySQL item should I adjust?