cli command which saves product fails when using magerun
Using magerun the command fails with error "Database lock wait timeout exceeded" but when using bin/magento saving is succesfull with no errors.
I made a simple console command module which reproduces the error https://github.com/juhanihaapala/module-magerun-bug
This pretty sure is related to issue #448
@juhanihaapala Thanks. I will try to verify that the next days.
@juhanihaapala I installed your module in a Magento 2.3.0.
I got "Area Code not set" exception.
This problem is well known. It a problem within\Magento\Framework\Session\SidResolver::getSid.
We deployed a fix for n98-magerun2 commands. For core Magento command I did not have solution.
If you add "@session_start();" before you set the area code, the exception is gone but I got a different error.
On my machine [Magento\Framework\Exception\NoSuchEntityException] The Product with the "test" SKU doesn't exist.
Should have said it in first place I was using Magento 2.3.1 and it seems to work differently in 2.3.0.
@juhanihaapala We have changed a lot of stuff in the upcoming v4.0.0. Can you please update to beta version and test again?
n98-magerun2.phar self-update --unstable
@cmuench I must have missed your comment, but testing now again with n98-magerun2 4.0.4 and latest Magento 2.3.5 I still get the error SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction.
When I last time was deep in magento with xdebug I remember seeign 2 different instances of objectmanager and both had similar instances.
Also now I enabled mysql general query log and it looks like it's starting transaction twice, and when second one is trying to insert image attribute gets stuck on waiting the other query to finish first:
3007 Query START TRANSACTION
3008 Query SELECT `catalog_product_entity`.`entity_id` FROM `catalog_product_entity` WHERE (entity_id = '2047') LIMIT 1
3008 Query START TRANSACTION
--snip--
3008 Query INSERT IGNORE INTO `catalog_product_entity_varchar` (`entity_id`,`attribute_id`,`store_id`,`value`) VALUES ('2047', '87', '1', '/c/o/codaone_logo_final.png'), ('2047', '88', '1', '/c/o/codaone_logo_final.png'), ('2047', '89', '1', '/c/o/codaone_logo_final.png'), ('2047', '133', '1', 'no_selection')
--snip--
3007 Query INSERT INTO `catalog_product_entity_varchar` (`attribute_id`,`store_id`,`entity_id`,`value`) VALUES ('87', '1', '2047', '/c/o/codaone_logo_final_7.png') ON DUPLICATE KEY UPDATE `attribute_id` = VALUES(`attribute_id`), `store_id` = VALUES(`store_id`), `entity_id` = VALUES(`entity_id`), `value` = VALUES(`value`)
3008 Query ROLLBACK
3007 Query ROLLBACK
We just ran into the same issue.
It happens in \Magento\Catalog\Model\Product\Gallery\CreateHandler::processMediaAttribute where the INSERT queries for catalog_product_entity_varchar run into the timeout.
Maybe we have relation to this issue here: #667
Just tested with latest n98-magerun2 v5.1.0. In the meantime we refactored the bootstrap process. Sadly the issue is still there and does not fix it.
We have refactored the way we handle Core Commands. Version 7.0.0 will hopefully fix this issue. Sadly the issue is so old that we cannot test it anymore against a Magento 2.3.x which had EOL. If the issue is reproducible in Magento 2.4.x, please re-open the issue.
@cmuench Finally I got time to test this again with latest Magerun 7.2.0 and with Magento 2.4.6-p3 and it seems to work now!