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

Add collation settings to allow collation to override charset #155

Merged
merged 11 commits into from
Jan 26, 2023

Conversation

dm-2
Copy link
Contributor

@dm-2 dm-2 commented Jan 23, 2023

This PR introduces two new settings:

  • ConfigurationSettings -> BackendCollation - if specified, sets collation=? in the DSN for the backend MySQL database connection, replacing the default charset=utf8mb4,utf8,latin1 setting
  • MySQLConfigurationSettings ->Collation - if specified, sets collation=? in the DSN for the monitored MySQL stores connections, replacing the default charset=utf8mb4,utf8,latin1 setting

When these values are set to a charset that is common between MySQL 5.7 and 8.0 (e.g. utf8mb4_unicode_520_ci), this prevents Freno from breaking temporary replication from an 8.0 primary to a 5.7 replica.

This PR does not change the existing behaviour of Freno (i.e. setting charset=utf8mb4,utf8,latin1); instead it allows the existing behaviour to be overriden when the new collation settings are specified.

I have not added the new collation parameters to the documentation as they are for a niche use case.

Also in this PR:

  • I have also adjusted one of the tests as Actions now results in invalid hosts returning a timeout instead of "no such host" (but the important part of the test is that it fails to connect to an invalid host)
  • Added Go 1.18 and 1.19 to supported versions

@dm-2 dm-2 requested review from latentflip and a team January 23, 2023 17:26
Copy link

@latentflip latentflip left a comment

Choose a reason for hiding this comment

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

👍 Looks good but just pattern matching based on existing code looks like we might want to rename one of the vars here.

pkg/config/config.go Outdated Show resolved Hide resolved
pkg/group/mysql.go Outdated Show resolved Hide resolved
pkg/group/mysql.go Outdated Show resolved Hide resolved
@dm-2 dm-2 requested a review from latentflip January 23, 2023 17:52
latentflip
latentflip previously approved these changes Jan 23, 2023
Copy link

@latentflip latentflip left a comment

Choose a reason for hiding this comment

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

👍 collation bits look good to me.

My only other thought is whether it's possible to add a test for this change? but otherwise 👍.

@@ -51,8 +51,8 @@ func TestProxySQLGetDB(t *testing.T) {
if err == nil {
t.Fatal("expected error for failed connection")
}
if !strings.HasSuffix(err.Error(), "no such host") {
t.Fatalf("expected a 'no such host' error, got %v", err)
if !strings.HasSuffix(err.Error(), "no such host") && !strings.HasSuffix(err.Error(), "i/o timeout") {

Choose a reason for hiding this comment

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

Is this change meant to be in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to fix a test failure when run in Actions, as the invalid host lookup now times out instead of returning "no such host" (but the important thing for this test is that connecting to an invalid hostname fails, which is still the case with this change). I've not dug further into why this has changed.

@dm-2
Copy link
Contributor Author

dm-2 commented Jan 24, 2023

My only other thought is whether it's possible to add a test for this change? but otherwise 👍.

Good shout - done 👍 There is a lot of logic driven from NewMySQLBackend in mysql.go, so I have broken out the DB URI code into its own separate function to simplify testing.

@dm-2 dm-2 requested a review from latentflip January 24, 2023 17:17
@dm-2 dm-2 temporarily deployed to staging January 25, 2023 14:36 Inactive
@dm-2 dm-2 temporarily deployed to staging January 25, 2023 16:41 Inactive
@dm-2 dm-2 temporarily deployed to staging January 26, 2023 14:07 Inactive
@dm-2 dm-2 merged commit 50c8a20 into master Jan 26, 2023
@dm-2 dm-2 deleted the add-collation-flag branch January 26, 2023 15:00
@dm-2 dm-2 restored the add-collation-flag branch January 26, 2023 15:54
@dm-2 dm-2 deleted the add-collation-flag branch January 26, 2023 15:57
@dm-2 dm-2 restored the add-collation-flag branch January 26, 2023 17:16
@dm-2 dm-2 deleted the add-collation-flag branch January 26, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants