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

Schema is always not up-to-date in 2.4.6 and MySQL 8.0.30 in some cases with real db fields #37543

Open
2 of 5 tasks
speller opened this issue May 25, 2023 · 15 comments
Open
2 of 5 tasks
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@speller
Copy link

speller commented May 25, 2023

Preconditions and environment

  • Magento version: 2.4.6
  • MySQL version 8.0.30

Steps to reproduce

  1. Run setup:upgrade

Expected result

The setup:db:status command reports that everything is up-to-date.

Actual result

Running setup:db:status always reports thath the schema is not up-to-date.

bin/magento setup:db:status
Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented May 25, 2023

Hi @speller. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board May 25, 2023
@engcom-Bravo engcom-Bravo added the Reported on 2.4.6 Indicates original Magento version for the Issue report. label May 25, 2023
@speller
Copy link
Author

speller commented May 25, 2023

The following workaround fixes the issue: #36558 (comment)

@engcom-Bravo engcom-Bravo self-assigned this May 25, 2023
@m2-assistant
Copy link

m2-assistant bot commented May 25, 2023

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo
Copy link
Contributor

HI @speller,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and Magento 2.4.6 and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

  • Run setup:upgrade

Magento 2.4.6 Instance

Screenshot 2023-05-25 at 1 41 34 PM

Magento 2.4 develop Instance

Screenshot 2023-05-25 at 1 41 42 PM

Kindly recheck the behaviour on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label May 25, 2023
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board May 25, 2023
@speller
Copy link
Author

speller commented May 25, 2023

@engcom-Bravo
I double-checked and found that the issue is caused by the module yotpo/module-yotpo-reviews. By some reason, the $elementStructuralData value in the \Magento\Framework\Setup\Declaration\Schema\Dto\ElementFactory::castGenericAttributes() method doesn't have the unsigned array key on unsigned fields (i.e. yotpo_orders_sync.yotpo_id, yotpo_product_sync.yotpo_id, etc).
We're using version 4.0.33
Since the unsigned array key is not set, but the field is unsigned, Magento always sees differences. This is why the mentioned workaround works.

The table structure is the following:

CREATE TABLE `yotpo_orders_sync` (
  `entity_id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
  `order_id` int unsigned NOT NULL COMMENT 'Order ID',
  `yotpo_id` double unsigned DEFAULT '0' COMMENT 'Yotpo ID',
  `synced_to_yotpo` datetime DEFAULT NULL COMMENT 'Synced to Yotpo',
  `response_code` varchar(5) DEFAULT NULL COMMENT 'Response Code',
  `is_fulfillment_based_on_shipment` tinyint(1) DEFAULT NULL COMMENT 'Fulfillment Sync Method',
  PRIMARY KEY (`entity_id`),
  UNIQUE KEY `YOTPO_ORDERS_SYNC_ORDER_ID` (`order_id`),
  KEY `YOTPO_ORDERS_SYNC_ENTITY_ID` (`entity_id`),
  KEY `YOTPO_ORDERS_SYNC_IS_FULFILLMENT_BASED_ON_SHIPMENT` (`is_fulfillment_based_on_shipment`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Orders sync with Yotpo';

@speller
Copy link
Author

speller commented May 25, 2023

Probably, the double unsigned type is the issue.

@speller
Copy link
Author

speller commented May 25, 2023

Yes, the issue is in the \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Columns\Real::fromDefinition() method that fails to process the double unsigned definition correctly:

image

The execution doesn't go into the if branch where the unsigned flag can be detected. The code just can not work with a real number without precision/scale specifiers. So this is definitely a Magento bug.

@speller speller changed the title Schema is always not up-to-date in 2.4.6 and MySQL 8.0.30 Schema is always not up-to-date in 2.4.6 and MySQL 8.0.30 in some cases with real db fields May 25, 2023
@engcom-Bravo
Copy link
Contributor

Hi @speller,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and Magento 2.4.6 still we are not able to reproduce the issue.Kindly refer the screenshots.

Screenshot 2023-06-01 at 1 39 28 PM Screenshot 2023-06-01 at 1 39 35 PM

It looks like issue caused by yotpo/module-yotpo-reviews.and it is an third party module.

Kindly recheck the issue on Magento 2.4-develop instance and check if any 3rd party extensions / modules enabled is causing this issue.

Thanks,

@speller
Copy link
Author

speller commented Jun 5, 2023

@engcom-Bravo

Third-party modules can not do anything here except what is allowed by the framework.

This is the definition of one of the columns that cause the issue:

        <column xsi:type="double" name="yotpo_id" unsigned="true" nullable="false" default="0" comment="Api Response Data - Yotpo ID"/>

Since Magento allows this and it causes problems, then this is a Magento issue. If the framework will not allow but the module will force by hacks then it will be the module issue. But the latter doesn't work here. The module uses the allowed schema and the framework can not handle this case properly.

@m2-assistant
Copy link

m2-assistant bot commented Jun 6, 2023

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo engcom-Bravo added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jun 6, 2023
@engcom-Hotel
Copy link
Contributor

Hello @speller,

Thanks for the report & contribution!

We have tried to reproduce this issue with Magento 2.4.6 and module yotpo/module-yotpo-reviews installed. But we are unable to reproduce the issue. Please have a look into the below screenshot for reference:

image

We have also verified the db_schema.xml file for the column definition and found the same definition as above:

<column xsi:type="double" name="yotpo_id" unsigned="true" nullable="false" default="0"
                comment="Api Response Data - Yotpo ID"/>

Please let us know in case we have missed anything.

Thanks

@speller
Copy link
Author

speller commented Jun 7, 2023

@engcom-Hotel
What setup:db:status command says in your case?

@engcom-Hotel
Copy link
Contributor

Hello @speller,

Below is the output of the bin/magento setup:db:status command:

image

And when we tried the above command after removing the yotpo modules then the output is as follows:

image

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Area: Framework and removed Issue: needs update Additional information is require, waiting for response labels Jun 7, 2023
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Jun 7, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-8943 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Jun 7, 2023

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
High Priority Backlog
  
Ready for Development
Development

No branches or pull requests

4 participants