When I clear cache, my menu ordering seems to go out of order When I clear cache, especially on high traffic times, my menu seems to go out of ordering. Usually I don't see any log messages except for one time:


  Message              Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: INSERT INTO {cache_render}


That time my ram and CPU also spiked. What I mean about go out of ordering is this:



The ul.menu-level-1 is suppose to be inside the div.container, but for some reason, when I clear cache, sometimes it's rendered outside the div.container.

I am using the menu items extra module module. It does not have an issue related to this. My network team is pretty adamant that the resources I have are sufficient and i hover about 30%-40% utilization normally for my ram and cpu. The web and database nodes are separate.

I am self-hosted and have cloudflare in front of my website. I do not have caching in cloudflare turned on. Does anyone have any suggestions on what this could be. It normally only happens on my production site - of course - but it's happened on my test sites in the past as well. That's why I don't think its cloudflare.
I believe this had something to do with mysql's setting max_allowed_packet. Mine was only set to 1MB, when drupal recommended 16mb.