n98-magerun2 icon indicating copy to clipboard operation
n98-magerun2 copied to clipboard

cli command which saves product fails when using magerun

Open juhanihaapala opened this issue 7 years ago • 9 comments

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

juhanihaapala avatar Apr 15 '19 14:04 juhanihaapala

This pretty sure is related to issue #448

juhanihaapala avatar Apr 16 '19 04:04 juhanihaapala

@juhanihaapala Thanks. I will try to verify that the next days.

cmuench avatar Apr 16 '19 09:04 cmuench

@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.

cmuench avatar Apr 16 '19 15:04 cmuench

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 avatar Apr 17 '19 09:04 juhanihaapala

@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 avatar Dec 29 '19 19:12 cmuench

@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

juhanihaapala avatar May 05 '20 14:05 juhanihaapala

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.

norgeindian avatar Jun 01 '21 13:06 norgeindian

Maybe we have relation to this issue here: #667

cmuench avatar Jun 12 '21 09:06 cmuench

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.

cmuench avatar May 10 '22 05:05 cmuench

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 avatar Jan 17 '23 19:01 cmuench

@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!

juhanihaapala avatar Dec 07 '23 07:12 juhanihaapala