File system cache clearByTags sometimes crash with file/directory error

Hello,

I’m using the Laminas Cache component with the filesystem adapter (and plugin serializer).
Here is what I use to initialize my cache object :

\Laminas\Cache\StorageFactory::factory
							(
								array
								(
									'adapter'	=>
										[
											'name'		=>	'filesystem',
											'options'	=>
												[
													'namespace' => 'My Name Space',
													'cache_dir' => '/my/cache/directory'
												]
										],
									'plugins'	=>	['serializer']
								)
							)

Sometimes (not always !) I’ve got file/directory error when I call the “clearByTags” method (with an array of few tags and disjunction to true), like :
[09-Mar-2022 17:29:49 Europe/Paris] PHP Fatal error: Uncaught ErrorException: rmdir(/home/web/variance-auto.com/www/site/temporaire/cache/outils/luminis-f3): The directory isn't empty in /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem.php:110
or
[10-Mar-2022 09:23:30 Europe/Paris] PHP Fatal error: Uncaught ErrorException: unlink(/my/directory/cache/outils/label-ac/label-111853527cf9967b9d6c81d2396ec04c.tag): No such file or directory in /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem.php:1658

Is that a known issue ? How can I fix it, please ?

Thanks for your precious helps.

Can you test the version 2 of this cache adapter? There are some reworks of the interaction with the file system.

Hello @froschdesign ! thanks for your reply.
Are you talking about the filesystem component version or the cache component version ?
Here is the version in use on my env :

I mean the cache adapter Filesystem but I see you use the older version 2 of laminas-cache and this means you can only use the version 1 of the Filesystem adapter.

Maybe you can test version 3 of laminas-cache and the Filesystem adapter with version 2 on your system.


By the way: You do not have to install all cache adapters, check the installation description for this.

Thanks for all of this @froschdesign !
Install OK !

I’ll make some tests and give a feedback about how it fix or not the problem.

Hello !

Sadly, updating to the latest version doesn’t seems to fix it : the error happen again :’(.

What does the error message actually look like?

@froschdesign same as previously.
There is CHMOD, UNLINK or RMDIR problem.
Here is an example :
[17-Mar-2022 05:02:49 Europe/Paris] PHP Fatal error: Uncaught ErrorException: rmdir(/my/directory/cache/outils/luminis-ac): Directory is not empty in /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem.php:173

Have you tried to set the permissions yourself? This can be done via adapter options:

Not sure about what you mean : changing “dir_permission/file_permission” value on my own ?
If yes, I’m not sure that’s the problem as much of case works pretty well currently. If it’s a permission problem, it shall never work, right ?

Dunno if it could help but I realize it happen kinda only on long execution time script…

Right, forget my last comment on that. I hadn’t remembered that the problem doesn’t always occur.

Could the problem be concurrent queries?

Hello @froschdesign !

Hm, it could be yes… how can I verify if it is concurent queries ?

Others examples of error I get in log (without stack trace - translated from french) :

[19-Mar-2022 05:01:13 Europe/Paris] PHP Fatal error:  Uncaught ErrorException: rmdir(/my/directory/cache/outils/luminis-c5): directory is not empty /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem.php:173
[19-Mar-2022 22:14:40 Europe/Paris] PHP Fatal error:  Uncaught ErrorException: fopen(/my/directory/cache/outils/luminis-ac/luminis-111853527cf9967b9d6c81d2396ec04c.dat): failed to open stream: no file/directory of the type in /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem/LocalFilesystemInteraction.php:172

And another one (without stack trace - translated from french) :
[21-Mar-2022 18:17:18 Europe/Paris] PHP Fatal error: Uncaught ErrorException: chmod(): no file/directory of this type in /my/directory/vendor/laminas/laminas-cache-storage-adapter-filesystem/src/Filesystem/LocalFilesystemInteraction.php:153

Any other ideas about this, please ? Anyone ?

Still pending… shall I open a issue on the project (that’s a real question ^^) ?

Try to ask in the Chat.