symfony: Compile error after cache clear and warmup

Q A
Bug report? yes
Feature request? no
BC Break report? -
RFC? no
Symfony version 3.4.2

This is related to #24885.

Fatal Compile Error: require(): Failed opening required '/.../cache/prod/Container3no4t0t/getSwiftmailer_EmailSender_ListenerService.php' (include_path='.:/usr/share/php')

I run a couple commands during deployment, clear cache, warm cache, other commands, and always get a Fatal Compile Error after the cache warmup:

php bin/console cache:clear --no-warmup --env=prod
php bin/console cache:warmup --env=prod
php bin/console rabbitmq-supervisor:rebuild -vv --no-interaction --env=prod

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

This is exactly where the problem lies. If you have long running processes, you will hit this error.

The processes have a path to the old container in memory, which doesn’t exist anymore after a cache rebuild.

I try to solve it by stopping the long running processes (Symfony commands) before I rebuild the cache, and start them again afterwards.

This still sometimes gives me an error when someone clears the cache directly via the commands, so this change is kind of annoying.

I upgraded (https://github.com/symfony/symfony/compare/29961b693fa2157a3f349d1a801f9f8742be4e03...1b36d0324681090ff1ca0d1d397b9f45c67612ed), but still have the issue. It is probably due to the fact that processes still look at the old container.

I’ll look in to it later and reopen this issue if it is a problem in Symfony.

I’ll have a look at 3.4@dev.

Currently having the issue in v3.4.2 (29961b693fa2).

So I had the same error showing up when deploying on prod since I updated to 3.4. I took the time to investigate this problem and found how to reproduce it.

Use this command on a fresh Symfony standard edition :

<?php

namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Process;

class TempCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('app:temp');
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return int
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $process = new Process('php bin/console cache:clear');
        $process->run();

        return 0;
    }
}

Works fine on 3.3, fails on 3.4.

untitled

Also I can confirm you that using the same fix as in https://github.com/symfony/symfony/pull/24908 is working here. If you have $this->getApplication()->setDispatcher(new EventDispatcher()); at the beginning of the command, there is no error.