Skip to content
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

First setup:upgrade fails on AddMollieShipmentIdAttribute patch #822

Open
LucaGallinari opened this issue Oct 14, 2024 · 6 comments
Open
Assignees
Labels
Question / Issue Further information is requested

Comments

@LucaGallinari
Copy link

Describe the bug
Sometimes, during the first setup:upgrade of the module, the procedure fails while adding the mollie_shipment_id to the sales_shipment table:

Module 'Hyva_Checkout':
Module 'MarkShust_DisableTwoFactorAuth':
Module 'Mollie_Payment':
Enabling caches:
Current status:
layout: 1
block_html: 1
full_page: 1
Unable to apply data patch Mollie\Payment\Setup\Patch\Data\AddMollieShipmentIdAttribute for module Mollie_Payment. Original exception message: DDL statements are not allowed in transactions
  error  in magento2.php on line 302:
exit code 1 (General error)

Theoretically this should always fails as you shouldn't be able to add a column via DataPatch, but sometimes, especially on the second run of the setup:upgrade, it adds the column properly without errors.

Btw, it should be replaced with a proper definition of the column via db_schema file.

Used versions

  • Magento Version number: 2.4.4-p9
  • Open source/Enterprise/B2b: open source
  • Mollie version number: 2.40.1
@Frank-Magmodules Frank-Magmodules self-assigned this Oct 15, 2024
@Frank-Magmodules Frank-Magmodules added the Investigating We are working on this issue together with the customer. label Oct 15, 2024
@Frank-Magmodules
Copy link
Collaborator

Hi @LucaGallinari,

Thank you for opening this issue and providing the details. We’ve had the setup scripts integrated into our Continuous Integration workflow for quite some time now, and we’ve never encountered this problem. Could it be that there is a conflict with another module in your setup?

@Frank-Magmodules Frank-Magmodules added Question / Issue Further information is requested and removed Investigating We are working on this issue together with the customer. labels Oct 21, 2024
@JeroenBoersma
Copy link

I just ran into exactly the same problem.

It only happens the first time you run the script, the second time everything is fine!

Installation: Clean Magento 2 with sample data!

$ composer require mollie/magento2
# default stuff
$ bin/magento setup:upgrade
# ....
Module 'Mollie_Payment':                                                                                 
Unable to apply data patch Mollie\Payment\Setup\Patch\Data\AddMollieShipmentIdAttribute for module Mollie_Payment. Original exception message: DDL statements are not allowed in transactions                      
$ bin/magento setup:upgrade
# OK

@Frank-Magmodules
Copy link
Collaborator

Thanks @JeroenBoersma , we will take a look into it!

@JeroenBoersma
Copy link

So, I can reproduce it time after time...

# install a clean Magento, nothing else and run setup:install
$ rm -rf generated
$ composer require mollie/magento2
$ bin/magento setup:upgrade --keep-generated
# ....
Module 'Mollie_Payment':                                                                                 
Unable to apply data patch Mollie\Payment\Setup\Patch\Data\AddMollieShipmentIdAttribute for module Mollie_Payment. Original exception message: DDL statements are not allowed in transactions                      
$ bin/magento setup:upgrade

So my last comment was incomplete, the --keep-generated messes things up! I know for sure that the flag was there when I commented earlier, but I didn't think it was part of the problem.

@LucaGallinari did you also use the --keep-generated flag? Just to find the common problem, as today I ran multiple scenarios but only this flag made the problem repeatable.

System settings:

  • Magento 2.4.7-p3
  • PHP 8.2.25 with zend opcache enabled
  • MariaDB 10.6
  • Redis 7.4.1
  • Opensearch 2.18.0
  • RabbitMQ 4.0.3

@Frank-Magmodules
Copy link
Collaborator

That’s helpful, @JeroenBoersma! We spent this morning trying to reproduce it, and now it seems we have a good lead on where and with what setup this might be happening. Thanks—I’ll follow up on this soon!

@LucaGallinari
Copy link
Author

@LucaGallinari did you also use the --keep-generated flag? Just to find the common problem, as today I ran multiple scenarios but only this flag made the problem repeatable.

It could be it! Locally i don't use that flag infact i never had this problem, instead on our CI/deploy we are using that flag and it failed on first "runs".

Btw, as i pointed out in the original post, the correct way to add a column is via a Declarative Schema and NOT via a DataPatch. We never run into this kind of problems by using declarative schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question / Issue Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants