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

Improve database collation detection #22594

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

mneudert
Copy link
Member

@mneudert mneudert commented Sep 17, 2024

Description:

The collation detection introduced in #22564 can create problems in some environments, most likely for MariaDB 11.4+.

In MariaDB 11.4+ the query SHOW COLLATION WHERE `Default` = "Yes" AND `Charset` = 'utf8mb4' does not return any result, and throwing an exception means a new installation is not possible. Showing the diagnostics page also crashes if no collation is configured.

When updating an existing Matomo installation, the update migration should detect a collation to prevent this problem. However, if there are already mixed tables (e.g. users table with general_ci and archive table with uca1400_ai_ci) this is not something we can be really sure of.

The check is changed to use SHOW CHARACTER SET instead. This should, at least for utf8mb4 character sets, always return a default we can use for installation/diagnostics. For utf8, or if there is no value found, it will now return an empty string. With the updated CREATE DATABASE statement, this should now allow installation for MariaDB 11.4+ again, and also for database setups that are not configured to handle utf8mb4.

Forcing utf8 charset detection during install

  • Start a database server, for example MySQL 8.0
  • Create a database with utf8mb3
    CREATE DATABASE matomo CHARSET utf8mb3;
  • Deactivate innodb_file_per_table for the server:
     SET GLOBAL innodb_file_per_table = OFF;
  • Proceed to install Matomo

The configuration should be created as [database] charset = utf8 (missing from config.ini.php because this is the default from global.ini.php), and no collation.

Review

@mneudert mneudert added Needs Review PRs that need a code review Stability For issues that make Matomo more stable and reliable to run for sys admins. labels Sep 17, 2024
@mneudert mneudert added this to the 5.2.0 milestone Sep 17, 2024
@mneudert mneudert requested a review from a team September 17, 2024 18:41
@mneudert mneudert added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Sep 24, 2024
@sgiehl sgiehl merged commit 6b9d136 into 5.x-dev Sep 25, 2024
23 of 25 checks passed
@sgiehl sgiehl deleted the improve-collation-detection branch September 25, 2024 16:31
jorgeuos pushed a commit to jorgeuos/matomo that referenced this pull request Oct 1, 2024
valentinab25 pushed a commit to valentinab25/matomo that referenced this pull request Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Stability For issues that make Matomo more stable and reliable to run for sys admins.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants