Home > database >  Symfony: var/cache/prod/pools is growing infinitely, what is causing this? How to avoid it?
Symfony: var/cache/prod/pools is growing infinitely, what is causing this? How to avoid it?

Time:06-29

I deployed a website running Symfony 4.4. This website has very low traffic, but run automatic tasks (commands) several times per hour. It uses Doctrine to connect to a MySQL 5.6 database.

After one day, the size of the var/cache/prod/pools directory has grown to 198M.

The problem is that the filesystem is slow with so many files, so removing the old files after a deployment take so much time that sometimes it fails.

The directory contains directories:

$ ls var/cache/prod/pools/NPSipMZaUK/0/
   -  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z

I looked at one file in a sub directory, it contains a Doctrine query and the mapping fields of the result. I see that an argument is written as is:

AND u0_.lastScan <= \'2022-06-13 23:21:52\'

So it looks like every query performed by Doctrine will create a file in this directory.


I don't have any specific configuration about Doctrine or the cache.

What process or configuration is creating the cache and all of these files? Are there options or alternatives to avoid creating all these files? The hosting provider (OVH) doesn't provide APCu or memcache.

The documentation about the cache doesn't mention this: https://symfony.com/doc/4.4/cache.html


Update: actually I was wrong, the project uses the default configuration from recipes and it defines the filesystem for storing the pools. Here is the documentation of the cache.

CodePudding user response:

This cache can be cleared by pruning it:

php bin/console cache:pool:prune

I will run this command automatically every day.

Source.

  • Related