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

Check mysql charset, if it's utf8, display an error log #24392

Closed
wants to merge 3 commits into from

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 28, 2023

This PR will check MySQL database charset when Gitea start. If it's utf8, an error log will be displayed.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 28, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 28, 2023
@wolfogre
Copy link
Member

The CI failure is related.

image

Hmm, so we used an incorrect database to test for years? 😂

@lunny
Copy link
Member Author

lunny commented Apr 28, 2023

It's wired, we never test emoji with our CI mysql services?

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 28, 2023

What about adding a "self check" page in site admin?

It could do a full self check, including:

  1. database versions (pgsql, mysql, etc)
  2. database charsets (mysql), not only just checking default, but check all columns.
  3. reverse proxy rewriting and sub path (eg: is %2F kept?)
  4. system time (to resolve incorrect OTP problems)
  5. system health like free disk, etc

@lunny
Copy link
Member Author

lunny commented Apr 28, 2023

What about adding a "self check" page in site admin?

It could do a full self check, including:

1. database versions (pgsql, mysql, etc)

2. database charsets (mysql), not only just checking default, but check all columns.

3. reverse proxy rewriting and sub path (eg: is `%2F` kept?)

4. system time (to resolve incorrect OTP problems)

5. system health like free disk, etc

sounds like web-based gitea doctor

@wxiaoguang
Copy link
Contributor

Yes, some checks could only be done by web UI (eg: 3, 4)

@silverwind
Copy link
Member

silverwind commented Apr 28, 2023

UI self check I'd say is out of scope for this PR, but I agree it might be useful.

}
if dbCharset == "utf8" {
log.Error("database charset is utf8 which is deprecated, please convert it to utf8mb4 and change your app.ini [database]charset")
}
Copy link
Member

@silverwind silverwind Apr 28, 2023

Choose a reason for hiding this comment

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

Also match for utf8mb3 which is an alias to utf8 and interpolate charset into the message.

Reference: https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html

@wxiaoguang
Copy link
Contributor

UI self check I'd say is out of scope for this PR, but I agree it might be useful.

But checking default charset is not enough. Every column should be checked one by one.

@lunny
Copy link
Member Author

lunny commented Apr 29, 2023

UI self check I'd say is out of scope for this PR, but I agree it might be useful.

But checking default charset is not enough. Every column should be checked one by one.

I think you are right, but we should not check them when start. It should be a backend task.

@wxiaoguang
Copy link
Contributor

UI self check I'd say is out of scope for this PR, but I agree it might be useful.

But checking default charset is not enough. Every column should be checked one by one.

I think you are right, but we should not check them when start. It should be a backend task.

That why I suggest to make an admin UI

@silverwind
Copy link
Member

Still not sure about UI.

How about actually refusing to start on wrong charset? Yes it's strict, but it's the only way to really ensure all users get it.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 29, 2023

IMO an admin UI is the only solution. See these 5 points (actually not only these)

We shouldn't stop Gitea from starting, and we should do full check (check every column) when checking. So we still need an admin UI.

@silverwind
Copy link
Member

silverwind commented Apr 29, 2023

How about doing a full table check and display a warning on frontpage to every admin user if issues were found? That should be a simple UI to add and would be better than something hidden away in the admin section. I assume a full table scan won't take so long.

For people concerned about startup performance, we could add a opt-out to these checks in config.

@techknowlogick
Copy link
Member

How about doing a full table check and display a warning on frontpage to every admin user if issues were found? That should be a simple UI to add and would be better than something hidden away in the admin section. I assume a full table scan won't take so long.

For people concerned about startup performance, we could add a opt-out to these checks in config.

Atlassian does exactly this (a full table check, and then reports in UI) for the datacentre version of their products, they aren't blocking on the boot of the server (IIRC) and so we could probably do something similar.

I agree re: having it block the startup for the check is bad. At the very least a one-off "on-boot" cron might be sufficient.

@lunny
Copy link
Member Author

lunny commented Jun 7, 2023

Close as this will break users' instances.

@lunny lunny closed this Jun 7, 2023
@lunny lunny deleted the lunny/check_mysql_charset branch June 7, 2023 04:09
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants