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

Reset the KEY_BLOCK_SIZE when migrating the MySQL engine and row format #2363

Merged
merged 8 commits into from
Oct 6, 2020

Conversation

aschempp
Copy link
Member

I have a Contao 4.6 setup on a server that did not support InnoDB. Therefore, I configured the DBAL like so which worked for about 2 years now.

doctrine:
    dbal:
        connections:
            default:
                charset: utf8
                default_table_options:
                    charset: utf8
                    collate: utf8_unicode_ci
                    engine: MyISAM

I could finally convince the client to move to a good hoster and also do an update to Contao 4.9. First step was to move the existing installation to the new hoster, on Contao 4.6 and with this DBAL configuration. Then I updated to Contao 4.9 and did run contao:migrate, which fails at migrating the tl_files table:

ALTER TABLE tl_files ENGINE = InnoDB ROW_FORMAT = DYNAMIC......FAILED
[ERROR] An exception occurred while executing 'ALTER TABLE tl_files ENGINE = InnoDB ROW_FORMAT = DYNAMIC':
SQLSTATE[HY000]: General error: 1031 Table storage engine for '#sql-10b9_2e20d0a' doesn't have this option

After a suggestion from @ausi I tried to set ROW_FORMAT=DEFAULT before changing the engine. Changing the row format worked, but I got a new error after that (this time in german due to phpMyAdmin).

error 1478 - Speicher-Engine 'InnoDB' der Tabelle unterstützt die Option 'KEY_BLOCK_SIZE' nicht

I did some digging on the internet and found the following to MySQL issues:

Apparently, my database table has a KEY_BLOCK_SIZE defined, but that's not supported by an DYNAMIC (uncompressed) row format. According to the second bug report, setting KEY_BLOCK_SIZE=0 is the correct way to remove that setting since MySQL 5.5.9

@aschempp aschempp added the bug label Sep 25, 2020
@aschempp aschempp added this to the 4.9 milestone Sep 25, 2020
@aschempp aschempp requested review from ausi and a team September 25, 2020 15:28
@aschempp aschempp self-assigned this Sep 25, 2020
@ausi
Copy link
Member

ausi commented Sep 25, 2020

Is setting KEY_BLOCK_SIZE supported in MySQL 5.1 too, or would this result in an error?

@aschempp
Copy link
Member Author

According to https://bugs.mysql.com/bug.php?id=56628 it has been fixed 5.1.55 and 5.5.9. Before that fix, it did trigger a warning for invalid value, but the keyword seems valid.

@m-vo
Copy link
Member

m-vo commented Sep 25, 2020

Before that fix, it did trigger a warning for invalid value, but the keyword seems valid

Is this also true when running in strict mode? And with MariaDB? 🙈

@aschempp
Copy link
Member Author

🤷 we'll never know…

@ausi
Copy link
Member

ausi commented Sep 28, 2020

I think we should check for false !== stripos($tableOptions->Create_options, 'key_block_size=') and only then add KEY_BLOCK_SIZE=0 to the query. This should still fix the issue but not create any warnings or errors.

@leofeyer
Copy link
Member

Is this also true when running in strict mode? And with MariaDB? 🙈

🤷 we'll never know…

Then we cannot merge this PR, can we? We would risk breaking installations.

@ausi
Copy link
Member

ausi commented Sep 28, 2020

Then we cannot merge this PR, can we? We would risk breaking installations.

I think we won’t break anything if we check the create options of the table as I suggested in #2363 (comment)

If the KEY_BLOCK_SIZE is already present in the create options, it should be save to unset it (by setting it to 0).

Copy link
Member

@leofeyer leofeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check for false !== stripos($tableOptions->Create_options, 'key_block_size=') and only then add KEY_BLOCK_SIZE=0 to the query. This should still fix the issue but not create any warnings or errors.

See #2363 (comment)

@aschempp
Copy link
Member Author

aschempp commented Oct 2, 2020

PR updated accordingly. I have tested this on my customer's database, which worked correctly. To adjust the unit tests, I had to rewrite the getInstaller to use the $fromSchema as source of truth instead of varying the configuration based on table name. Also noticed that the installation-bundle was missing in the phpunit.xml.dist, therefore coverage was not generated for it.

@leofeyer
Copy link
Member

leofeyer commented Oct 2, 2020

Also noticed that the installation-bundle was missing in the phpunit.xml.dist, therefore coverage was not generated for it.

That is intended.

phpunit.xml.dist Outdated Show resolved Hide resolved
@aschempp
Copy link
Member Author

aschempp commented Oct 2, 2020

Can you explain why that would be intended? Except for we're too lazy to write tests 😝

@leofeyer
Copy link
Member

leofeyer commented Oct 2, 2020

The bundle is deprecated and will hopefully be replaced by the Contao Manager soon, therefore we had decided not to write tests and not to track coverage.

@aschempp
Copy link
Member Author

aschempp commented Oct 2, 2020

that sounds fair. But doesn't that mean the installer should be moved to the core-bundle then?

@leofeyer
Copy link
Member

leofeyer commented Oct 2, 2020

Probably yes. I think there is a ticket for that already.

installation-bundle/src/Database/Installer.php Outdated Show resolved Hide resolved
installation-bundle/src/Database/Installer.php Outdated Show resolved Hide resolved
installation-bundle/tests/Database/InstallerTest.php Outdated Show resolved Hide resolved
installation-bundle/tests/Database/InstallerTest.php Outdated Show resolved Hide resolved
@aschempp aschempp requested review from ausi and leofeyer October 4, 2020 06:23
ausi
ausi previously approved these changes Oct 4, 2020
installation-bundle/src/Database/Installer.php Outdated Show resolved Hide resolved
Co-authored-by: Martin Auswöger <martin@auswoeger.com>
@leofeyer leofeyer merged commit 0e10f0b into contao:4.9 Oct 6, 2020
@leofeyer leofeyer changed the title Reset the KEY_BLOCK_SIZE when migrating mysql engine and row format Reset the KEY_BLOCK_SIZE when migrating the MySQL engine and row format Oct 6, 2020
@aschempp aschempp deleted the bugfix/innodb-keyblocksize branch October 10, 2020 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants