Towny Classic

Towny Classic

3.2k Downloads

MySQL Collation Compatibility Error

madebygood opened this issue · 10 comments

commented

What steps will reproduce the problem?

  1. Start the Minecraft server with Towny enabled.
  2. Let the plugin connect to a MySQL database using utf8mb4_0900_ai_ci collation.
  3. Observe server logs during player data save operations.

What is the expected output?

Towny should insert or update resident data in the database without collation conversion errors or warnings.

Towny version

0.101.1.9

Server version

1.20.1 Paper

Please use Pastebin.com to link the following files

Image

commented
commented

What is utf8mb4_0900_ai_ci collation and why do you use it?

I didn't manually configure any collation. I've been using MySQL 8.0, and utf8mb4_0900_ai_ci has always been the default collation when creating databases or tables with the utf8mb4 charset.

This bug only started appearing after I updated to Towny version 0.101.1.7 -> 0.101.1.9. I’ve used several previous versions of Towny without any issues, and this is the first time I’ve encountered this specific collation-related warning.

Due to this issue, my latest.log file grew to over 150GB and towny.log reached 194GB, which eventually caused the server to freeze completely. I believe this is a critical bug that should be addressed. Please investigate if it’s related to changes in this version. Even if it’s unrelated, I hope this report helps.

commented
commented

Towny doesn't specify any collation when creating columns in the database, so these two must be coming purely from your database server's side of things. Did any updates to it happen recently, and what's the actual collation the columns are using now?

We haven't had any other reports of this happening recently, so it's likely not tied to any difference between towny versions.

commented

Towny doesn't specify any collation when creating columns in the database, so these two must be coming purely from your database server's side of things. Did any updates to it happen recently, and what's the actual collation the columns are using now?

We haven't had any other reports of this happening recently, so it's likely not tied to any difference between towny versions.

Title
Infinite WARN spam: “Conversion from collation utf8mb4_0900_ai_ci into utf8mb3_general_ci impossible” when an emoji is used in “/nation set title”

Content
When a player enters the command
/​nation set title nickname &6💰
the console begins printing the following warning dozens of times per second and never stops:

[Folia Async Scheduler Thread #517/WARN]: [Towny] SQL: Conversion from collation utf8mb4_0900_ai_ci into utf8mb3_general_ci impossible for parameter --> HikariProxyPreparedStatement@… UPDATE TOWNY_RESIDENTS …

The title column (and several others) in TOWNY_RESIDENTS is still created with the collation utf8mb3_general_ci. MySQL 8 refuses to cast the 4‑byte emoji to that older 3‑byte collation and throws error 3988, so Towny keeps retrying the same statement and the log floods continuously. The command never completes and the repeated warnings degrade server usability.

How to reproduce: create a fresh server with the versions above, keep Towny’s default database schema, then run the command that includes any utf8mb4 emoji such as 💰. The warnings begin immediately and never stop.

Expected behaviour: utf8mb4 characters should be stored without warnings; the command should succeed once.

Probable cause and proposed solution: Towny’s schema generator needs to create all string columns with utf8mb4_0900_ai_ci (or at least migrate title, nation‑ranks, town‑ranks, etc. to that collation). Alternatively, on load, the plugin could detect an old schema and run an automatic migration.

If more logs or details are needed, let me know and I will provide them.

commented

Currently, this vulnerability allows an attacker to exploit Towny by repeatedly executing such commands, potentially overwhelming the server’s resources and filling up disk space with endless log spam. This can effectively cripple the host machine. A prompt fix is strongly recommended.

commented

Don't post AI generated stuff here, thanks.

This is not some vulnerability in towny, but rather a poor choice of default when you created your towny database. At most we can specify a default charset or collation to use when creating new tables, I don't feel comfortable with changing the collation automatically for every single towny server out there.

commented

You skipped the form and I cannot see your towny config.

commented

You skipped the form and I cannot see your towny config.

Thank you very much for your attempt to help.
I’d like to share my config settings in case it might be helpful.

I’m running a server based in South Korea, and in my case, I’ve allowed Korean characters in the string_check_regex setting.
This configuration is commonly used by many server operators in Korea.

I’m mentioning this just in case it could be related to the issue.
I hope this information is of some help. Thank you again.

database.txt
config.txt

commented

The screenshot of your error says conversion from utf8mb4_0900_ai_ci to utf8mb3_general_ci, but utf8mb3_general_ci is only a 3 byte unicode encoding option that doesn't support the full character set. Figure out what part of your system has been configured to use utf8mb3_general_ci and change it to the newer utf8mb4_general_ci