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

Magento's setup:db:status fails with MySQL 8.0.29 #35671

Closed
1 of 5 tasks
lbajsarowicz opened this issue Jun 23, 2022 · 19 comments
Closed
1 of 5 tasks

Magento's setup:db:status fails with MySQL 8.0.29 #35671

lbajsarowicz opened this issue Jun 23, 2022 · 19 comments
Labels
Area: Upgrades - Upgrade Compatibility Tool Component: Setup 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: done Reported on 2.4.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@lbajsarowicz
Copy link
Contributor

lbajsarowicz commented Jun 23, 2022

Preconditions and environment

  • Magento 2.4.4
  • MySQL 8.0.29 and higher --- Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)

Steps to reproduce

  1. Set up Magento 2.4.4 following the requirements (https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html)
  2. Execute setup:upgrade
  3. Execute setup:db:status

Expected result

Magento should report that the Database is up-to-date

Actual result

  1. bin/magento setup:db:status

Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

  1. bin/magento setup:upgrade
  2. bin/magento setup:db:status

Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

  1. bin/magento setup:db-schema:upgrade
  2. bin/magento setup:db:status

Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

Additional information

Issue is caused by charset comparison.

Beginning with MySQL 8.0.28, utf8mb3 is also displayed in place of utf8 in columns of Information Schema tables, and in the output of SQL SHOW statements.

Prior to MySQL 8.0.29, instances of utf8mb3 in statements were converted to utf8. In MySQL 8.0.30 and later, the reverse is true, so that in statements such as SHOW CREATE TABLE or SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLUMNS or SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS, users see the character set or collation name prefixed with utf8mb3 or utf8mb3_.

image

The default table charset is defined in \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Table::create
image

Our internal workaround is a plugin which overrides default MySQL charset if no other provided:

<?php
declare(strict_types=1);

namespace SwiftOtter\MysqlCharsetFix\Plugin;

use Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Table;

class OverrideDefaultCharsetPlugin
{
    private const DEFAULT_CHARSET = 'utf8mb3';

    /**
     * @param Table $subject
     * @param array $data
     * @return array
     */
    public function beforeCreate(Table $subject, array $data): array
    {
        if (!isset($data['charset'])) {
            $data['charset'] = self::DEFAULT_CHARSET;
        }

        return [$data];
    }
}

Another possible solution is to override \Magento\Framework\Setup\Declaration\Schema\Dto\Table::getDiffSensitiveParams parameters, excluding charset from the list. (Composer patch below)

diff --git a/Setup/Declaration/Schema/Dto/Table.php b/Setup/Declaration/Schema/Dto/Table.php
--- a/Setup/Declaration/Schema/Dto/Table.php
+++ b/Setup/Declaration/Schema/Dto/Table.php	(date 1655976014788)
@@ -343,7 +343,6 @@
             'resource' => $this->getResource(),
             'engine' => $this->getEngine(),
             'comment' => $this->getComment(),
-            'charset' => $this->getCharset(),
             'collation' => $this->getCollation()
         ];
     }

Huge thanks for helping with the investigation to @LeeSaferite, @navarr, and @so-max-u

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 Jun 23, 2022

Hi @lbajsarowicz. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ 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.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Jun 24, 2022

Hi @engcom-November. 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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components 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-November
Copy link
Contributor

Hi @lbajsarowicz ,
Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop branch with php 8.1 and the issue is reproducible. Hence confirming this issue.
image

@engcom-November engcom-November added Component: Setup Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Upgrades - Upgrade Compatibility Tool Reported on 2.4.4 Indicates original Magento version for the Issue report. Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jun 24, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Jun 24, 2022
nemke82 added a commit to magemojo/m2-patches that referenced this issue Jun 24, 2022
Fix for setup:db:status in 2.4.4 based on magento/magento2#35671
nemke82 added a commit to magemojo/m2-patches that referenced this issue Jun 24, 2022
@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jun 24, 2022
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Jun 24, 2022
@tgreeve
Copy link

tgreeve commented Jun 27, 2022

This issue is reproducible in 2.4.3-p2.
image

@engcom-November engcom-November 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 Area: Upgrades - Upgrade Compatibility Tool and removed 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 Area: Upgrades - Upgrade Compatibility Tool labels Jul 15, 2022
@github-jira-sync-bot
Copy link

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

@m2-assistant
Copy link

m2-assistant bot commented Jul 15, 2022

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, 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 Jul 15, 2022
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Sep 22, 2022
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Sep 22, 2022
@joachimVT
Copy link

Having the same issue,
Creating a plugin

Does not fix this issue. After a successful deploy running setup:db:status still shows:
Declarative Schema is not up to date

@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue Progress: dev in progress and removed Progress: dev in progress labels Oct 17, 2022
@m2-community-project m2-community-project bot removed the Progress: PR Created Indicates that Pull Request has been created to fix issue label Oct 18, 2022
@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue Progress: dev in progress and removed Progress: dev in progress labels Nov 14, 2022
@m2-community-project m2-community-project bot removed the Progress: PR Created Indicates that Pull Request has been created to fix issue label Nov 15, 2022
@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: dev in progress labels Nov 25, 2022
@speller
Copy link

speller commented Dec 2, 2022

I'm having the same issue. The schema is always not up to date. The \Magento\Framework\Setup\Declaration\Schema\Diff\Diff::$changes variable always has 400 entries and all of them are related to utf8mb3.
Magento 2.4.5
PHP 8.1.13
MySQL version 8.0.30

@speller
Copy link

speller commented Dec 2, 2022

As a workaround, I'm using the following patch with the cweagans/composer-patches component:

--- a/Setup/Declaration/Schema/Dto/Factories/Table.php
+++ b/Setup/Declaration/Schema/Dto/Factories/Table.php
@@ -23,12 +23,12 @@
     /**
      * Default charset for SQL
      */
-    public const DEFAULT_CHARSET = 'utf8';
+    public const DEFAULT_CHARSET = 'utf8mb3';

     /**
      * Default collation
      */
-    public const DEFAULT_COLLATION = 'utf8_general_ci';
+    public const DEFAULT_COLLATION = 'utf8mb3_general_ci';

     /**
      * @var ObjectManagerInterface

It solves the problem with changes caused by encodings. I had other issues as well (#36558), so this workaround patch is not guaranteed to fix all issues.

@magenx magenx mentioned this issue Dec 3, 2022
5 tasks
@leonhelmus
Copy link

leonhelmus commented Dec 7, 2022

I think this means we need to update the charset in the database to utf8, since that's a reference at the moment for utf8mb3 and will be updated to a reference to utf8mb4. see:
https://stackoverflow.com/a/52337457

same for utf8mb3_general_ci that needs to be updated to utf8_general_ci. Or am i wrong?
@engcom-November

@hostep
Copy link
Contributor

hostep commented Jan 10, 2023

Closed without an explanation telling why?

Possibly fixed by AC-7469: Add support for MySQL8.0.29 and higher ?

@nocturnalfrog
Copy link

@hostep; I guess some habits are hard to kick. 😉

@engcom-Hotel
Copy link
Contributor

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-5970 by the internal team
Related commits: https://github.com/magento/magento2/search?q=AC-7469&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

@jonathanribas
Copy link

Hi all,

utf8mb3 character set is actually deprecated on MySQL 8, we should use utfmb4 instead.

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-sets.html#:~:text=This%20character%20set%20is%20deprecated%20in%20MySQL%208.0%2C%20and%20you%20should%20use%20utfmb4%20instead

@navarr
Copy link
Member

navarr commented Mar 21, 2023

@jonathanribas No disagreement - but Magento currently uses utf8mb3 and this issue is about fixing it not recognizing it.

A new issue should be created to move off the deprecated charset

@jonathanribas
Copy link

There is already one for utfmb4 support: #35174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Upgrades - Upgrade Compatibility Tool Component: Setup 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: done Reported on 2.4.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

No branches or pull requests