schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
335 stars 254 forks source link

Invalid argument supplied for foreach() in /var/www-aura/releases/34/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php line 125 #158

Closed ickbinhier closed 7 years ago

ickbinhier commented 7 years ago

Hello,

this messages become i every 30 minutes ...

is this a problem in the JMSJobQueueBundle?

Stack Trace

at in vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php at line 125 
         */
        public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
        {
            foreach ($this->getPropertyAnnotations($property) as $annot) {
                if ($annot instanceof $annotationName) {
                    return $annot;
                }

at Elao\ErrorNotifierBundle\Listener\Notifier ->handlePhpError 2, 'Invalid argument supplied for foreach()', '/var/www-aura/releases/34/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php', 125, array('property' => object(ReflectionProperty), 'annotationName' => 'Doctrine\\ORM\\Mapping\\Cache')
in vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php at line 125 
         */
        public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
        {
            foreach ($this->getPropertyAnnotations($property) as $annot) {
                if ($annot instanceof $annotationName) {
                    return $annot;
                }

at Doctrine\Common\Annotations\CachedReader ->getPropertyAnnotation object(ReflectionProperty), 'Doctrine\\ORM\\Mapping\\Cache'
in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php at line 292 
                $mapping['fieldName'] = $property->getName();
                // Evaluate @Cache annotation
                if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Cache::class)) !== null) {
                    $mapping['cache'] = $metadata->getAssociationCacheDefaults(
                        $mapping['fieldName'],
                        [

at Doctrine\ORM\Mapping\Driver\AnnotationDriver ->loadMetadataForClass 'JMS\\JobQueueBundle\\Entity\\Job', object(ClassMetadata)
in vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php at line 102 
            /* @var $driver MappingDriver */
            foreach ($this->drivers as $namespace => $driver) {
                if (strpos($className, $namespace) === 0) {
                    $driver->loadMetadataForClass($className, $metadata);
                    return;
                }
            }

at Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain ->loadMetadataForClass 'JMS\\JobQueueBundle\\Entity\\Job', object(ClassMetadata)
in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php at line 151 
            // Invoke driver
            try {
                $this->driver->loadMetadataForClass($class->getName(), $class);
            } catch (ReflectionException $e) {
                throw MappingException::reflectionFailure($class->getName(), $e);
            }

at Doctrine\ORM\Mapping\ClassMetadataFactory ->doLoadMetadata object(ClassMetadata), null, false, array()
in vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php at line 332 
                $class = $this->newClassMetadataInstance($className);
                $this->initializeReflection($class, $reflService);
                $this->doLoadMetadata($class, $parent, $rootEntityFound, $visited);
                $this->loadedMetadata[$className] = $class;

at Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory ->loadMetadata 'JMS\\JobQueueBundle\\Entity\\Job'
in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php at line 78 
         */
        protected function loadMetadata($name)
        {
            $loaded = parent::loadMetadata($name);
            array_map([$this, 'resolveDiscriminatorValue'], array_map([$this, 'getMetadataFor'], $loaded));

at Doctrine\ORM\Mapping\ClassMetadataFactory ->loadMetadata 'JMS\\JobQueueBundle\\Entity\\Job'
in vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php at line 216 
                        $this->wakeupReflection($cached, $this->getReflectionService());
                    } else {
                        foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
                            $this->cacheDriver->save(
                                $loadedClassName . $this->cacheSalt,
                                $this->loadedMetadata[$loadedClassName],

at Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory ->getMetadataFor 'JMS\\JobQueueBundle\\Entity\\Job'
in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php at line 283 
         */
        public function getClassMetadata($className)
        {
            return $this->metadataFactory->getMetadataFor($className);
        }
        /**

at Doctrine\ORM\EntityManager ->getClassMetadata 'JMS\\JobQueueBundle\\Entity\\Job'
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 1740 
            $token = $this->lexer->lookahead;
            $aliasIdentificationVariable = $this->AliasIdentificationVariable();
            $classMetadata = $this->em->getClassMetadata($abstractSchemaName);
            // Building queryComponent
            $queryComponent = [

at Doctrine\ORM\Query\Parser ->RangeVariableDeclaration
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 1588 
        public function IdentificationVariableDeclaration()
        {
            $joins                    = [];
            $rangeVariableDeclaration = $this->RangeVariableDeclaration();
            $indexBy                  = $this->lexer->isNextToken(Lexer::T_INDEX)
                ? $this->IndexBy()
                : null;

at Doctrine\ORM\Query\Parser ->IdentificationVariableDeclaration
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 1323 
            $this->match(Lexer::T_FROM);
            $identificationVariableDeclarations = [];
            $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration();
            while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
                $this->match(Lexer::T_COMMA);

at Doctrine\ORM\Query\Parser ->FromClause
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 884 
         */
        public function SelectStatement()
        {
            $selectStatement = new AST\SelectStatement($this->SelectClause(), $this->FromClause());
            $selectStatement->whereClause   = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null;
            $selectStatement->groupByClause = $this->lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null;

at Doctrine\ORM\Query\Parser ->SelectStatement
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 853 
            switch ($this->lexer->lookahead['type']) {
                case Lexer::T_SELECT:
                    $statement = $this->SelectStatement();
                    break;
                case Lexer::T_UPDATE:

at Doctrine\ORM\Query\Parser ->QueryLanguage
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 269 
        public function getAST()
        {
            // Parse & build AST
            $AST = $this->QueryLanguage();
            // Process any deferred validations of some nodes in the AST.
            // This also allows post-processing of the AST for modification purposes.

at Doctrine\ORM\Query\Parser ->getAST
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 365 
         */
        public function parse()
        {
            $AST = $this->getAST();
            if (($customWalkers = $this->query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) {
                $this->customTreeWalkers = $customWalkers;

at Doctrine\ORM\Query\Parser ->parse
in vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 281 
            // Cache miss.
            $parser = new Parser($this);
            $this->_parserResult = $parser->parse();
            $queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL);

at Doctrine\ORM\Query ->_parse
in vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 293 
         */
        protected function _doExecute()
        {
            $executor = $this->_parse()->getSqlExecutor();
            if ($this->_queryCacheProfile) {
                $executor->setQueryCacheProfile($this->_queryCacheProfile);

at Doctrine\ORM\Query ->_doExecute
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 968 
                };
            }
            $stmt = $this->_doExecute();
            if (is_numeric($stmt)) {
                $setCacheEntry($stmt);

at Doctrine\ORM\AbstractQuery ->executeIgnoreQueryCache null, 1
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 923 
                return $this->executeUsingQueryCache($parameters, $hydrationMode);
            }
            return $this->executeIgnoreQueryCache($parameters, $hydrationMode);
        }
        /**

at Doctrine\ORM\AbstractQuery ->execute null, 1
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 726 
         */
        public function getResult($hydrationMode = self::HYDRATE_OBJECT)
        {
            return $this->execute(null, $hydrationMode);
        }
        /**

at Doctrine\ORM\AbstractQuery ->getResult
in vendor/jms/job-queue-bundle/JMS/JobQueueBundle/Command/RunCommand.php at line 394 
            $staleJobs = $this->getEntityManager()->createQuery("SELECT j FROM ".Job::class." j WHERE j.state = :running AND (j.workerName = :worker OR j.workerName IS NULL)")
                ->setParameter('worker', $workerName)
                ->setParameter('running', Job::STATE_RUNNING)
                ->getResult();
            foreach ($staleJobs as $job) {
                // If the original job has retry jobs, then one of them is still in

at JMS\JobQueueBundle\Command\RunCommand ->cleanUpStaleJobs 'aura-31674'
in vendor/jms/job-queue-bundle/JMS/JobQueueBundle/Command/RunCommand.php at line 126 
                $this->output->writeln('Cleaning up stale jobs');
            }
            $this->cleanUpStaleJobs($workerName);
            $this->runJobs(
                $workerName,

at JMS\JobQueueBundle\Command\RunCommand ->execute object(ArgvInput), object(ConsoleOutput)
in vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php at line 255 
            if ($this->code) {
                $statusCode = call_user_func($this->code, $input, $output);
            } else {
                $statusCode = $this->execute($input, $output);
            }
            return is_numeric($statusCode) ? (int) $statusCode : 0;

at Symfony\Component\Console\Command\Command ->run object(ArgvInput), object(ConsoleOutput)
in vendor/symfony/symfony/src/Symfony/Component/Console/Application.php at line 852 
            if ($event->commandShouldRun()) {
                try {
                    $e = null;
                    $exitCode = $command->run($input, $output);
                } catch (\Exception $x) {
                    $e = $x;
                } catch (\Throwable $x) {

at Symfony\Component\Console\Application ->doRunCommand object(RunCommand), object(ArgvInput), object(ConsoleOutput)
in vendor/symfony/symfony/src/Symfony/Component/Console/Application.php at line 191 
            $command = $this->find($name);
            $this->runningCommand = $command;
            $exitCode = $this->doRunCommand($command, $input, $output);
            $this->runningCommand = null;
            return $exitCode;

at Symfony\Component\Console\Application ->doRun object(ArgvInput), object(ConsoleOutput)
in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php at line 80 
            $this->setDispatcher($container->get('event_dispatcher'));
            return parent::doRun($input, $output);
        }
        /**

at Symfony\Bundle\FrameworkBundle\Console\Application ->doRun object(ArgvInput), object(ConsoleOutput)
in vendor/jms/job-queue-bundle/JMS/JobQueueBundle/Console/Application.php at line 45 
            $this->input = $input;
            try {
                $rs = parent::doRun($input, $output);
                $this->saveDebugInformation();
                return $rs;

at JMS\JobQueueBundle\Console\Application ->doRun object(ArgvInput), object(ConsoleOutput)
in vendor/symfony/symfony/src/Symfony/Component/Console/Application.php at line 122 
            $this->configureIO($input, $output);
            try {
                $exitCode = $this->doRun($input, $output);
            } catch (\Exception $e) {
                if (!$this->catchExceptions) {
                    throw $e;

at Symfony\Component\Console\Application ->run object(ArgvInput)
in bin/console at line 28 
    $kernel = new AppKernel($env, $debug);
    $application = new Application($kernel);
    $application->run($input);
rommsen commented 7 years ago

We have the same problem. This problem only occurs with Symfony 3.2. It works fine with Symfony 3.1. I havent found a reason for this yet. Furthermore I can not create new Jms Jobs:

  [Doctrine\DBAL\Exception\NotNullConstraintViolationException]                                                                                                                                                                                   
  An exception occurred while executing 'INSERT INTO jms_jobs (id, state, priority, createdAt, startedAt, checkedAt, executeAfter, closedAt, command, args, output, errorOutput, exitCode, maxRuntime, maxRetries, stackTrace, runtime, memoryUs  
  age, memoryUsageReal, originalJob_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [31, "pending", 0, "2017-01-06 14:18:41", null, null, "2017-01-06 14:18:40", null, "ipark:application:geo_locate_addres  
  s", "[\"--type=site\",\"--id=4cdb1a65-6ba5-49e2-a24d-cc0fdb01b3ba\"]", null, null, null, 0, 0, "N;", null, null, null, null]:                                                                                                                   
  SQLSTATE[23502]: Not null violation: 7 FEHLER:  NULL-Wert in Spalte »queue« verletzt Not-Null-Constraint                                                                                                                                        
  DETAIL:  Fehlgeschlagene Zeile enthält (31, pending, null, 0, 2017-01-06 14:18:41, null, null, 2017-01-06 14:18:40, null, ipark:application:geo_locate_address, ["--type=site","--id=4cdb1a65-6ba5-49e2-a24d-cc0fdb01b3ba"], null, null, null,  
   0, 0, \x4e3b, null, null, null, null). 

The queue is NULL. No clue why (also only with Symfony 3.2)

rommsen commented 7 years ago

Ok, this seems to be a combined composer doctrine/annotations problem. For the records: https://github.com/doctrine/annotations/issues/115#issuecomment-270930626, /cc @ickbinhier

schmittjoh commented 7 years ago

Should be fixed upstream now, closing this one here.