-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Bug] Illegal mix of collations with MariaDB 11.5+ #22536
Comments
Hey @felixlabrot, |
Hey @sgiehl! |
Hey @felixlabrot, we checked what happens with the most recent MariaDB version, and were able to reproduce the problem. It looks like this change from MariaDB The issue is indeed linked to a changed collation default, being problematic due to the way Matomo connects to the database (and the tables are created). Locally it was possible to fix the error by adding a new configuration value to the database (see MDEV-30164):
No extensive testing has been done except running archiving, so please be aware of this if you want to change your configuration! Some more details on reproduction and the source, assuming the Matomo is configured with In a default MariaDB
During archiving, queries like the following (modified from original query) will be executed: SELECT name
FROM archive_blob_2024_08
WHERE idarchive IN (1,2,3) AND (name = 'Actions_sitesearch' OR (name LIKE 'Actions_sitesearch%' AND (SUBSTRING(name, 19, 7) = '_chunk_' OR (SUBSTRING(name, 20, 1) >= '0' AND SUBSTRING(name, 20, 1) <= '9'))))
ORDER BY CAST(IF((@idsubtable := SUBSTRING(SUBSTRING(name, IF(SUBSTRING(name, 19, 7) = '_chunk_', 26, 20)), 1, IF((@secondunderscore := LOCATE('_', SUBSTRING(name, IF(SUBSTRING(name, 19, 7) = '_chunk_', 26, 20))) - 1) < 0, LENGTH(name), @secondunderscore))) = '', -1, @idsubtable ) AS SIGNED) ASC; After upgrading to MariaDB
Changing the query a bit makes it work (adding a collation to SELECT name
FROM archive_blob_2024_08
WHERE idarchive IN (1,2,3) AND (name = 'Actions_sitesearch' OR (name LIKE 'Actions_sitesearch%' AND (SUBSTRING(name, 19, 7) = '_chunk_' OR (SUBSTRING(name, 20, 1) >= '0' AND SUBSTRING(name, 20, 1) <= '9'))))
ORDER BY CAST(IF((@idsubtable := SUBSTRING(SUBSTRING(name COLLATE utf8mb4_uca1400_ai_ci, IF(SUBSTRING(name, 19, 7) = '_chunk_', 26, 20)), 1, IF((@secondunderscore := LOCATE('_', SUBSTRING(name, IF(SUBSTRING(name, 19, 7) = '_chunk_', 26, 20))) - 1) < 0, LENGTH(name), @secondunderscore))) = '', -1, @idsubtable ) AS SIGNED) ASC; A different solution would be to update the database connection init command:
This would also lets the query run without an error. Though there is no configuration available to fetch the to-be-used collation from, and a static value will probably become a problem with the various database environments Matomo runs in. However, as mentioned in MDEV-30164, a configuration variable was introduced and, as of MariaDB
With the description of "@@collation_connection after a SET NAMES without COLLATE", setting the value at the server level works. |
Hey @mneudert!
|
Hi @felixlabrot, your database configuration should not be at fault. Can you check if
Once Matomo connects to the database there are several points where the character set is getting messed with, one of them being Simply removing all of those commands and parameters does not fix the issue in my test instance. Modifying the code to use |
Hi @mneudert, running |
This issue has been mentioned on Matomo forums. There might be relevant details there: |
Since PR #22564 won't touch installations that have already upgraded MariaDB (and may already have a mix of tables) and will intentionally fail to update, should we add a docs page somewhere on how to fix the issue manually? |
@DaAwesomeP Thanks for mentioning that. Yes, we have planned to create an FAQ for that with details how to solve the problem and will mention that also in the release notes. |
When will a fixed version be provided for Docker? I upgraded just now to the latest version and it's still v5.1.1 and the issue is still there. |
It was yet only released in a release candidate. We are planning the final release for this week. But I'm unable to say how fast the docker image will be updated, as I'm not involved in that process. |
Just checking in on when the patch release may be released. It doesn't look like there have been any more commits to the |
@DaAwesomeP as you can see above, at the moment we are planning for the stable version to go out this week. |
This issue has been mentioned on Matomo forums. There might be relevant details there: |
I can confirm that the issue is indeed resolved and the repair guide works. |
What happened?
Since a few days the archiving job throws on 3 of 8 websites the error
Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8mb4_uca1400_ai_ci,COERCIBLE) for operation '=' - in plugin Actions.
The database default collection is
utf8mb4_general_ci
and so are all tables created since June 2021. Tables created before June 2021 areutf8mb4_unicode_ci
. There is no table withutf8mb4_uca1400_ai_ci
charset.Database is MariaDB 11.5.2.
What should happen?
The archive job should complete without errors in 3 of 8 websites.
How can this be reproduced?
run the archive job
Matomo version
5.1.1
PHP version
8.2.22
Server operating system
Docker
What browsers are you seeing the problem on?
No response
Computer operating system
No response
Relevant log output
Validations
The text was updated successfully, but these errors were encountered: