vegandthecity / magento

vegandthecity.ch/shop (Magento 2) source code and issues tracking
https://upwork.com/fl/mage2pro
1 stars 1 forks source link

«Deadlock found when trying to get lock; try restarting transaction, query was: DELETE FROM `cron_schedule` <…>» #18

Open dmitrii-fediuk opened 4 years ago

dmitrii-fediuk commented 4 years ago
[2020-04-07 16:58:03] main.ERROR: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: DELETE FROM `cron_schedule` WHERE (status = 'missed') AND (job_code in ('scconnector_verify_website', 'scconnector_retrieve_gtag')) AND (created_at < '2020-04-07 06:58:03')
#0 vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(613): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('DELETE FROM `cr...', Array)
#1 vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(664): Magento\Framework\DB\Adapter\Pdo\Mysql->query('DELETE FROM `cr...')
#2 vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(543): Zend_Db_Adapter_Abstract->delete('cron_schedule', '(status = 'miss...')
#3 vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(239): Magento\Cron\Observer\ProcessCronQueueObserver->cleanupJobs('scconnector', 1586278683)
#4 vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(269): Magento\Cron\Observer\ProcessCronQueueObserver->Magento\Cron\Observer\{closure}('scconnector')
#5 vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(242): Magento\Cron\Observer\ProcessCronQueueObserver->lockGroup('scconnector', Object(Closure))
#6 vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute(Object(Magento\Framework\Event\Observer))
#7 vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Cron\Observer\ProcessCronQueueObserver), Object(Magento\Framework\Event\Observer))
#8 vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#9 generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('default', Array)
#10 vendor/magento/framework/App/Cron.php(86): Magento\Framework\Event\Manager\Proxy->dispatch('default')
#11 vendor/magento/module-cron/Console/Command/CronCommand.php(117): Magento\Framework\App\Cron->launch()
#12 vendor/symfony/console/Command/Command.php(255): Magento\Cron\Console\Command\CronCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent('run', Array)
#15 vendor/mage2pro/core/Cron/Plugin/Console/Command/CronCommand.php(24): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 vendor/magento/framework/Interception/Interceptor.php(135): Df\Cron\Plugin\Console\Command\CronCommand->aroundRun(Object(Magento\Cron\Console\Command\CronCommand\Interceptor), Object(Closure), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(26): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins('run', Array, NULL)
#19 vendor/symfony/console/Application.php(893): Magento\Cron\Console\Command\CronCommand\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Magento\Cron\Console\Command\CronCommand\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 vendor/symfony/console/Application.php(145): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 bin/magento(23): Symfony\Component\Console\Application->run()
#24 {main} [] []
dmitrii-fediuk commented 4 years ago
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: DELETE FROM `cron_schedule` WHERE (status = 'missed') AND (job_code in ('scconnector_verify_website', 'scconnector_retrieve_gtag')) AND (created_at < '2020-04-07 06:58:03')
************************************
Location:    vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91
Callee:      PDOStatement::execute
Context:     
}
        }

        if ($specialExecute) {
            return $this->_executeWithBinding($params);
        } else {
            return $this->tryExecute(function () use ($params) {
                return $params !== null ? $this->_stmt->execute($params) : $this->_stmt->execute();
            });
        }
    }

    /**
     * Executes query and avoid warnings.
     *
     * @param callable $callback
*****************1******************
Location:    vendor/magento/framework/DB/Statement/Pdo/Mysql.php:107
Callee:      Magento\Framework\DB\Statement\Pdo\Mysql::Magento\Framework\DB\Statement\Pdo\{closure}
Context:     
private function tryExecute($callback)
    {
        $previousLevel = error_reporting(\E_ERROR); // disable warnings for PDO bugs #63812, #74401
        try {
            return $callback();
        } catch (\PDOException $e) {
            $message = sprintf('%s, query was: %s', $e->getMessage(), $this->_stmt->queryString);
            throw new \Zend_Db_Statement_Exception($message, (int)$e->getCode(), $e);
        } finally {
            error_reporting($previousLevel);
        }
    }
*****************2******************
Location:    vendor/magento/framework/DB/Statement/Pdo/Mysql.php:92
Callee:      Magento\Framework\DB\Statement\Pdo\Mysql::tryExecute
Context:     
}

        if ($specialExecute) {
            return $this->_executeWithBinding($params);
        } else {
            return $this->tryExecute(function () use ($params) {
                return $params !== null ? $this->_stmt->execute($params) : $this->_stmt->execute();
            });
        }
    }
*****************3******************
Location:    vendor/magento/zendframework1/library/Zend/Db/Statement.php:303
Callee:      Magento\Framework\DB\Statement\Pdo\Mysql::_execute
Context:     
public function execute(array $params = null)
    {
        /*
         * Simple case - no query profiler to manage.
         */
        if ($this->_queryId === null) {
            return $this->_execute($params);
        }

        /*
         * Do the same thing, but with query profiler
         * management before and after the execute.
         */
        $prof = $this->_adapter->getProfiler();
        $qp = $prof->getQueryProfile($this->_queryId);
*****************4******************
Location:    vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
Callee:      Zend_Db_Statement::execute
Context:     
// because $bind may be a Zend_Db_Expr object
        if (!is_array($bind)) {
            $bind = array($bind);
        }

        // prepare and execute the statement with profiling
        $stmt = $this->prepare($sql);
        $stmt->execute($bind);

        // return the results embedded in the prepared statement object
        $stmt->setFetchMode($this->_fetchMode);
        return $stmt;
    }
*****************5******************
Location:    vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
Callee:      Zend_Db_Adapter_Abstract::query
Context:     
unset($bind[$name]);
                    $bind[$newName] = $value;
                }
            }
        }

        try {
            return parent::query($sql, $bind);
        } catch (PDOException $e) {
            /**
             * @see Zend_Db_Statement_Exception
             */
            #require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
*****************6******************
Location:    vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:546
Callee:      Zend_Db_Adapter_Pdo_Abstract::query
Context:     
$triesCount = 0;
        do {
            $retry = false;
            $this->logger->startTimer();
            try {
                $this->_checkDdlTransaction($sql);
                $this->_prepareQuery($sql, $bind);
                $result = parent::query($sql, $bind);
                $this->logger->logStats(LoggerInterface::TYPE_QUERY, $sql, $bind, $result);
                return $result;
            } catch (\Exception $e) {
                // Finalize broken query
                $profiler = $this->getProfiler();
                if ($profiler instanceof Profiler) {
                    /** @var Profiler $profiler */
                    $profiler->queryEndLast();
*****************7******************
Location:    vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:613
Callee:      Magento\Framework\DB\Adapter\Pdo\Mysql::_query
Context:     
public function query($sql, $bind = [])
    {
        if (strpos(rtrim($sql, " \t
\r\0;"), ';') !== false && count($this->_splitMultiQuery($sql)) > 1) {
            throw new \Magento\Framework\Exception\LocalizedException(
                new Phrase("Multiple queries can't be executed. Run a single query and try again.")
            );
        }
        return $this->_query($sql, $bind);
    }
*****************8******************
Location:    vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:664
Callee:      Magento\Framework\DB\Adapter\Pdo\Mysql::query
Context:     
$sql = "DELETE FROM "
             . $this->quoteIdentifier($table, true)
             . (($where) ? " WHERE $where" : '');

        /**
         * Execute the statement and return the number of affected rows
         */
        $stmt = $this->query($sql);
        $result = $stmt->rowCount();
        return $result;
    }
*****************9******************
Location:    vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:543
Callee:      Zend_Db_Adapter_Abstract::delete
Context:     
$count = 0;
        foreach ($historyLifetimes as $status => $time) {
            $count += $connection->delete(
                $scheduleResource->getMainTable(),
                [
                    'status = ?' => $status,
                    'job_code in (?)' => array_keys($jobs),
                    'created_at < ?' => $connection->formatDate($currentTime - $time)
                ]
            );
        }

        if ($count) {
            $this->logger->info(sprintf('%d cron jobs were cleaned', $count));
        }
    }
*****************10*****************
Location:    vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:239
Callee:      Magento\Cron\Observer\ProcessCronQueueObserver::cleanupJobs
Context:     
);
                continue;
            }

            $this->lockGroup(
                $groupId,
                function ($groupId) use ($currentTime, $jobsRoot) {
                    $this->cleanupJobs($groupId, $currentTime);
                    $this->generateSchedules($groupId);
                    $this->processPendingJobs($groupId, $jobsRoot, $currentTime);
                }
            );
        }
    }

    /**
*****************11*****************
Location:    vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:269
Callee:      Magento\Cron\Observer\ProcessCronQueueObserver::Magento\Cron\Observer\{closure}
Context:     
"Could not acquire lock for cron group: %s, skipping run",
                    $groupId
                )
            );
            return;
        }
        try {
            $callback($groupId);
        } finally {
            $this->lockManager->unlock(self::LOCK_PREFIX . $groupId);
        }
    }
*****************12*****************
Location:    vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:242
Callee:      Magento\Cron\Observer\ProcessCronQueueObserver::lockGroup
Context:     
$this->lockGroup(
                $groupId,
                function ($groupId) use ($currentTime, $jobsRoot) {
                    $this->cleanupJobs($groupId, $currentTime);
                    $this->generateSchedules($groupId);
                    $this->processPendingJobs($groupId, $jobsRoot, $currentTime);
                }
            );
        }
    }
*****************13*****************
Location:    vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
Callee:      Magento\Cron\Observer\ProcessCronQueueObserver::execute
Context:     
protected function _callObserverMethod($object, $observer)
    {
        if ($object instanceof \Magento\Framework\Event\ObserverInterface) {
            $object->execute($observer);
        } elseif ($this->_appState->getMode() == State::MODE_DEVELOPER) {
            throw new \LogicException(
                sprintf(
                    'Observer "%s" must implement interface "%s"',
                    get_class($object),
                    \Magento\Framework\Event\ObserverInterface::class
                )
            );
*****************14*****************
Location:    vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
Callee:      Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod
Context:     
}

        if (isset($configuration['shared']) && false === $configuration['shared']) {
            $object = $this->_observerFactory->create($configuration['instance']);
        } else {
            $object = $this->_observerFactory->get($configuration['instance']);
        }
        $this->_callObserverMethod($object, $observer);
    }
*****************15*****************
Location:    vendor/magento/framework/Event/Manager.php:66
Callee:      Magento\Framework\Event\Invoker\InvokerDefault::dispatch
Context:     
$event = new \Magento\Framework\Event($data);
            $event->setName($eventName);

            $wrapper = new Observer();
            $wrapper->setData(array_merge(['event' => $event], $data));

            \Magento\Framework\Profiler::start('OBSERVER:' . $observerConfig['name']);
            $this->_invoker->dispatch($observerConfig, $wrapper);
            \Magento\Framework\Profiler::stop('OBSERVER:' . $observerConfig['name']);
        }
        \Magento\Framework\Profiler::stop('EVENT:' . $eventName);
    }
*****************16*****************
Location:    generated/code/Magento/Framework/Event/Manager/Proxy.php:95
Callee:      Magento\Framework\Event\Manager::dispatch
Context:     
public function dispatch($eventName, array $data = [])
    {
        return $this->_getSubject()->dispatch($eventName, $data);
    }
*****************17*****************
Location:    vendor/magento/framework/App/Cron.php:86
Callee:      Magento\Framework\Event\Manager\Proxy::dispatch
Context:     
$configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class);
        $this->objectManager->configure($configLoader->load(Area::AREA_CRONTAB));

        $this->areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);

        /** @var \Magento\Framework\Event\ManagerInterface $eventManager */
        $eventManager = $this->objectManager->get(\Magento\Framework\Event\ManagerInterface::class);
        $eventManager->dispatch('default');
        $this->_response->setCode(0);
        return $this->_response;
    }
*****************18*****************
Location:    vendor/magento/module-cron/Console/Command/CronCommand.php:117
Callee:      Magento\Framework\App\Cron::launch
Context:     
$bootstrapOptionValue = $bootstrapOptionValues[ProcessCronQueueObserver::STANDALONE_PROCESS_STARTED];
            if ($bootstrapOptionValue) {
                $params[ProcessCronQueueObserver::STANDALONE_PROCESS_STARTED] = $bootstrapOptionValue;
            }
        }
        /** @var \Magento\Framework\App\Cron $cronObserver */
        $cronObserver = $objectManager->create(\Magento\Framework\App\Cron::class, ['parameters' => $params]);
        $cronObserver->launch();
        $output->writeln('<info>' . 'Ran jobs by schedule.' . '</info>');
    }
*****************19*****************
Location:    vendor/symfony/console/Command/Command.php:255
Callee:      Magento\Cron\Console\Command\CronCommand::execute
Context:     
}

        $input->validate();

        if ($this->code) {
            $statusCode = ($this->code)($input, $output);
        } else {
            $statusCode = $this->execute($input, $output);
        }

        return is_numeric($statusCode) ? (int) $statusCode : 0;
    }
*****************20*****************
Location:    vendor/magento/framework/Interception/Interceptor.php:58
Callee:      Symfony\Component\Console\Command\Command::run
Context:     
public function ___callParent($method, array $arguments)
    {
        return parent::$method(...array_values($arguments));
    }
*****************21*****************
Location:    vendor/magento/framework/Interception/Interceptor.php:138
Callee:      Magento\Cron\Console\Command\CronCommand::___callParent
Context:     
$code = $currentPluginInfo[DefinitionInterface::LISTENER_AROUND];
                $pluginInfo = $pluginList->getNext($type, $method, $code);
                $pluginInstance = $pluginList->getPlugin($type, $code);
                $pluginMethod = 'around' . $capMethod;
                $result = $pluginInstance->$pluginMethod($subject, $next, ...array_values($arguments));
            } else {
                // Call original method
                $result = $subject->___callParent($method, $arguments);
            }

            if (isset($currentPluginInfo[DefinitionInterface::LISTENER_AFTER])) {
                // Call 'after' listeners
                foreach ($currentPluginInfo[DefinitionInterface::LISTENER_AFTER] as $code) {
                    $pluginInstance = $pluginList->getPlugin($type, $code);
                    $pluginMethod = 'after' . $capMethod;
                    $result = $pluginInstance->$pluginMethod($subject, $result, ...array_values($arguments));
*****************22*****************
Location:    vendor/mage2pro/core/Cron/Plugin/Console/Command/CronCommand.php:24
Callee:      Magento\Cron\Console\Command\CronCommand::Magento\Framework\Interception\{closure}
Context:     
function aroundRun(Sb $sb, \Closure $f, II $i, IO $o) {
        try {return $f($i, $o);}
        catch (\Exception $e) {
            df_log_e($e, $this);
            throw $e;
        }
    }
*****************23*****************
Location:    vendor/magento/framework/Interception/Interceptor.php:135
Callee:      Df\Cron\Plugin\Console\Command\CronCommand::aroundRun
Context:     
if (isset($currentPluginInfo[DefinitionInterface::LISTENER_AROUND])) {
                // Call 'around' listener
                $code = $currentPluginInfo[DefinitionInterface::LISTENER_AROUND];
                $pluginInfo = $pluginList->getNext($type, $method, $code);
                $pluginInstance = $pluginList->getPlugin($type, $code);
                $pluginMethod = 'around' . $capMethod;
                $result = $pluginInstance->$pluginMethod($subject, $next, ...array_values($arguments));
            } else {
                // Call original method
                $result = $subject->___callParent($method, $arguments);
            }

            if (isset($currentPluginInfo[DefinitionInterface::LISTENER_AFTER])) {
                // Call 'after' listeners
                foreach ($currentPluginInfo[DefinitionInterface::LISTENER_AFTER] as $code) {
*****************24*****************
Location:    vendor/magento/framework/Interception/Interceptor.php:153
Callee:      Magento\Cron\Console\Command\CronCommand::Magento\Framework\Interception\{closure}
Context:     
$result = $pluginInstance->$pluginMethod($subject, $result, ...array_values($arguments));
                }
            }

            return $result;
        };

        $result = $next(...array_values($arguments));
        $next = null;

        return $result;
    }
*****************25*****************
Location:    generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php:26
Callee:      Magento\Cron\Console\Command\CronCommand::___callPlugins
Context:     
public function run(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
    {
        $pluginInfo = $this->pluginList->getNext($this->subjectType, 'run');
        if (!$pluginInfo) {
            return parent::run($input, $output);
        } else {
            return $this->___callPlugins('run', func_get_args(), $pluginInfo);
        }
    }
*****************26*****************
Location:    vendor/symfony/console/Application.php:893
Callee:      Magento\Cron\Console\Command\CronCommand::run
Context:     
foreach ($command->getHelperSet() as $helper) {
            if ($helper instanceof InputAwareInterface) {
                $helper->setInput($input);
            }
        }

        if (null === $this->dispatcher) {
            return $command->run($input, $output);
        }

        // bind before the console.command event, so the listeners have access to input options/arguments
        try {
            $command->mergeApplicationDefinition();
            $input->bind($command->getDefinition());
        } catch (ExceptionInterface $e) {
            // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
*****************27*****************
Location:    vendor/symfony/console/Application.php:262
Callee:      Symfony\Component\Console\Application::doRunCommand
Context:     
return 1;
            }

            $command = $this->find($alternative);
        }

        $this->runningCommand = $command;
        $exitCode = $this->doRunCommand($command, $input, $output);
        $this->runningCommand = null;

        return $exitCode;
    }
*****************28*****************
Location:    vendor/magento/framework/Console/Cli.php:115
Callee:      Symfony\Component\Console\Application::doRun
Context:     
public function doRun(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
    {
        $exitCode = null;
        try {
            $exitCode = parent::doRun($input, $output);
        } catch (\Exception $e) {
            $errorMessage = $e->getMessage() . PHP_EOL . $e->getTraceAsString();
            $this->logger->error($errorMessage);
            $this->initException = $e;
        }

        if ($this->initException) {
            throw $this->initException;
*****************29*****************
Location:    vendor/symfony/console/Application.php:145
Callee:      Magento\Framework\Console\Cli::doRun
Context:     
$phpHandler[0]->setExceptionHandler($debugHandler);
            }
        }

        $this->configureIO($input, $output);

        try {
            $exitCode = $this->doRun($input, $output);
        } catch (\Exception $e) {
            if (!$this->catchExceptions) {
                throw $e;
            }

            $renderException($e);

            $exitCode = $e->getCode();
*****************30*****************
Location:    bin/magento:23
Callee:      Symfony\Component\Console\Application::run
Context:     
echo 'Autoload error: ' . $e->getMessage();
    exit(1);
}
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
    $application->run();
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "

";
        $e = $e->getPrevious();
    }
    exit(Magento\Framework\Console\Cli::RETURN_FAILURE);