-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doubled MySQL connection issue when runnig console command via magerun #667
Comments
@niclashoyer thanks for the report. Sadly it will be hard to reproduce the behavior in a vanilla Magento installation. If we can reporoduce the issue in a Magento 2.3 or 2.4 we will deploy a fix for that. The Magento 2.x is is out of support at Magento and we decided that the current n98-magerun2 release will only test and support the official supported Magento versions. Can you give me some informations about the custom command. How do you inject the "$_productRepository"? Is it using the |
The repository is injected via constructor injection using DI (not in the console command itself, but in another class that is then injected to the console command via constructor injection): public function __construct(
ProductRepositoryInterface $productRepository,
…
) {
$this->_productRepository = $productRepository;
…
} |
Oh as I now saw the importer class is actually "injected" via protected function execute(
InputInterface $input,
OutputInterface $output
) {
$this->_import = $this->_objectManager->get('\Example\ImportCatalog\Model\ImportCatalog');
… which obviously is bad practice, but may explain the strange behavior. I'll see if the issue is gone if I change that to constructor DI. |
No, unfortunately the issue is still there when using only DI constructor injection. |
We found an issue that we initialized Magento twice. That issue is fixed in the latest n98-magerun2 v5.1.0. |
Describe the bug
We noticed a strange behavior when starting a console command via magerun2. The command itself is implemented in an extension and imports products into the magento database using the
ProductRepository
-Interfaces. So, we load the productthen update / add data and later save it again
If we are running this via
bin/magento example:import
everything works as expected. But if we are starting this command viamagerun2 example:import
the import hangs on the save call and after some time we get the MySQL errorExpected behaviour
The command should run the same way as if started with
bin/magento
.Steps to reproduce the issue
We can't provide a minimal example at this point, so we'd first need to figure out how to reproduce this with minimal effort.
Technical details
Additional context
Upon debugging this we found out that if the command is run via magerun that two connections are opened to the database, which then lock themselves (in the log below ID 96 and 97). If we are using
bin/magento
directly it only opens one connection.show queries
The text was updated successfully, but these errors were encountered: