Magento 2.2.x – Fixing Cache Disabled Automatically Issue

cachemagento2magento2.2

First of all, I couldn't find any info about this kind of issue anywhere on the web.

We have a production environment with git integration. We pull our changes to it only via git (git pull).

The problem is that , somehow in one of the steps Magento caches disables automatically (all zeros when checking cache:status). That causes a problem if this is missed via programmer further causing server overload due to high traffic 'bashing' to the Magento without cache.

Maybe some of you have seen this issue before? We do not know when or how it's exactly happens.
And it kinda appears randomly.

Usual steps we do:

  • enabling maintenance
  • git pull
  • composer install (if needed)
  • module enable Vendor_ModuleName (if needed)
  • setup:upgrade (if needed)
  • clearing static stuff
  • deployment command
  • clearing caches
  • clearing opcache
  • disabling maintenance

I would appreciate any valuable suggestions that could help to solve this kind of issue.

Best Answer

This looks like a known issue:
This does happen from time to time on the project I'm working on, but I wasn't able to find the steps to reproduce. All I can say is that it happens during a deployment process.
All I could find is that under certain circumstances a file .regenerate is written in the var folder (either at setup upgrade or composer install / upgrade) and if that file is present when running setup:di:compile the cache is disabled and re-enabled when the compilation process is finished.
For some reason, sometimes the cache is not re-enabled.
We took the quick and dirty approach and made the last step of the deployment process php bin/magento cache:enable to be sure. SO basically we hid the dirt under the rug.

You can find the code that disables the cache in here
It is wrapped in a TODO: remove statement.

Related Topic