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

feat(support-mysql-8): Added support for mysql version 8.0 and above #170

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sairaj18
Copy link

@sairaj18 sairaj18 commented Dec 26, 2024

The query cache variables are removed from MySQL 8.0 - https://dev.mysql.com/doc/refman/5.7/en/query-cache-status-and-maintenance.html - Due to this the following metrics will not be support for mysql version 8.0 and above

  1. db.qCacheFreeBlocks
  2. db.qCacheFreeMemoryBytes
  3. db.qCacheHitRatio
  4. db.qCacheHitsPerSecond
  5. db.qCacheInserts
  6. db.qCacheLowmemPrunesPerSecond
  7. db.qCacheNotCachedPerSecond
  8. db.qCacheQueriesInCachePerSecond
  9. db.qCacheTotalBlocks
  10. db.qCacheUtilization

From MySQL 8.0.23 the statement CHANGE MASTER TO is deprecated. The alias CHANGE REPLICATION SOURCE TO should be used instead. The parameters for the statement also have aliases that replace the term MASTER with the term SOURCE. For example, MASTER_HOST and MASTER_PORT can now be entered as SOURCE_HOST and SOURCE_PORT.
More Info - https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-23.html.

Code changes -

  • Updated the existing code to support MySQL versions b/w 5.6.0 - 8.0.0 and versions greater than 8.0.0
  • Updated unit test for the same
  • Added integration tests for mysql versions 8.0.40 and 9.1.0

Testing details here

@sairaj18 sairaj18 marked this pull request as ready for review December 26, 2024 10:11
@sairaj18 sairaj18 requested a review from a team as a code owner December 26, 2024 10:11
@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from 25a2167 to 6d1792b Compare December 26, 2024 14:52
@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from 6d1792b to 62e1c0a Compare December 26, 2024 15:09
Copy link
Contributor

@rajrohanyadav rajrohanyadav left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this.

Left some comments. Some more points:

  1. Also, a lot of new functions are added without unit tests. I think it makes sense to add tests for the ones that have logical statements.
  2. Do you think it improves the code if we have an optional argument in config with db version? We won't have to compute version on each execution. If not specified, we anyways do it.
  3. IMO, the additional dependency is not required. But we can discuss.
  4. Can version throughout the code be replaced with dbVersion or something similar. It could be confused with integration version.

go.mod Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
src/default_metrics.go Show resolved Hide resolved
src/extended_metrics.go Show resolved Hide resolved
src/default_metrics.go Outdated Show resolved Hide resolved
src/extended_metrics.go Outdated Show resolved Hide resolved
}

func threadCacheMissRate(metrics map[string]interface{}) (float64, bool) {
// TODO compute the value within the interval
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't understand the TODO statement here.

Copy link
Author

Choose a reason for hiding this comment

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

this is already existing comment that just moved to different file

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to understand why it is there. If we think we don't need it, it can be removed.

Comment on lines 183 to 203
func extractSemver(version string) (string, error) {
reg := regexp.MustCompile(`^(?P<major>\d+)(?:\.(?P<minor>\d+))?(?:\.(?P<patch>\d+))?`)
matches := reg.FindStringSubmatch(version)

if len(matches) == 0 || matches[1] == "" {
return "", errSemanticVersionNotFound
}

major := matches[1]
minor := "0"
patch := "0"

if len(matches) > 2 && matches[2] != "" {
minor = matches[2]
}
if len(matches) > 3 && matches[3] != "" {
patch = matches[3]
}

return fmt.Sprintf("%s.%s.%s", major, minor, patch), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this much complexity for getting the version. MySQL Doc specifies that the version might have a suffix but not a prefix. Therefore, you'll always get version before the first -.
Moreover, the documentation states: This function is unsafe for statement-based replication. A warning is logged if you use this function when [binlog_format](https://dev.mysql.com/doc/refman/8.4/en/replication-options-binary-log.html#sysvar_binlog_format) is set to STATEMENT. Though the binlog_format is deprecated, do you think it might cause any issues for older customer environments?

Copy link
Author

Choose a reason for hiding this comment

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

will discuss this with kai

Copy link
Author

Choose a reason for hiding this comment

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

I ran integration tests in github actions for version 5.7.35 with binlog_format=STATEMENT and it passed. I didn’t make any change to handle if we are not able to parse DB version output. So, We are getting the version as excepted without any warning with was mentioned in the Mysql doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just note this in the documentation. Other than that it seems fine.

src/slave_metrics.go Outdated Show resolved Hide resolved
@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from 1dc1da9 to 9a5c77a Compare December 31, 2024 03:47
@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from 9a5c77a to fe29f92 Compare December 31, 2024 03:50
@sairaj18
Copy link
Author

sairaj18 commented Dec 31, 2024

Thanks for taking care of this.

Left some comments. Some more points:

  1. Also, a lot of new functions are added without unit tests. I think it makes sense to add tests for the ones that have logical statements.
  2. Do you think it improves the code if we have an optional argument in config with db version? We won't have to compute version on each execution. If not specified, we anyways do it.
  3. IMO, the additional dependency is not required. But we can discuss.
  4. Can version throughout the code be replaced with dbVersion or something similar. It could be confused with integration version.
  1. Added unit tests for the new functions that have been introduced.
  2. We can check the optional argument configuration with kai
  3. removed the additional dependency as we discussed
  4. replaced version with dbVersion in most of the code wherever needed

@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from 3754b63 to fe29f92 Compare December 31, 2024 11:57
@sairaj18 sairaj18 force-pushed the NR-133316-add-support-for-mysql-version-8-and-above branch from fdeaa60 to 5f06db8 Compare January 2, 2025 12:10
rajrohanyadav
rajrohanyadav previously approved these changes Jan 2, 2025
Copy link
Contributor

@rajrohanyadav rajrohanyadav left a comment

Choose a reason for hiding this comment

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

LGTM

Just one point as mentioned in my last comment. It also provides a way to not break the integration if we are unable to get version.

Do you think it improves the code if we have an optional argument in config with db version? We won't have to compute version on each execution. If not specified, we anyways do it.

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.

2 participants