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

mysqld system metrics, with TabletManager rpc #16850

Merged
merged 18 commits into from
Oct 1, 2024

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented Sep 26, 2024

Description

Addresses #16822. This is part of the multi-metrics throttler project.

Part 1, to be included in v21:

  • Adding mysqlctl.HostMetrics RPC, which returns a map[metric-name]metric-value, e.g. metrics["loadavg"]={...Value: 1.234}
  • Mysql Daemon implements the above rpc. Can be called to supply metrics read from its local OS.
  • Adding tabletmanager.MysqlHostMetrics, which is an access point to the above. TabletManager is the entity that holds a MysqlDaemon, thus is the only one able to call mysqlctl.HostMetrics RPC.
  • Likewise, TabletManagerClient supports MysqlHostMetrics() function, so that anyone can query a given tablet for its MySQL OS metrics.

This is all wired in this PR, ie if you call tmclient. TabletManagerClient, you get the actual OS metrics read by MysqlDaemon.

However, for 1-version backwards compatibility, this code path is not used anywhere.

We wish to merge this in v21, and immediately follow up with a PR (designed for v22) where the tablet throttler collects these metrics. It will do so sparsely.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Sep 26, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Sep 26, 2024
cell string
keyspace string
shard string
tabletAlias *topodatapb.TabletAlias
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 change (and everything in this file) is a small refactor. It is not strictly required for this PR, but will be needed in part 2, so I thought I may as well do it now.

@shlomi-noach shlomi-noach removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Sep 26, 2024
}
defer closer.Close()

resp, err := c.MysqlSystemMetrics(ctx, req)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A fully functional TabletManagerClient implementation. Not used by anyone right now for 1-version backwards support. This is what the throttler will use in the future.

@@ -275,6 +275,18 @@ func (tm *TabletManager) ExecuteFetchAsApp(ctx context.Context, req *tabletmanag
return sqltypes.ResultToProto3(result), err
}

// MysqlSystemMetrics gets system metrics from the MySQL deamon
func (tm *TabletManager) MysqlSystemMetrics(ctx context.Context, req *tabletmanagerdatapb.MysqlSystemMetricsRequest) (*tabletmanagerdatapb.MysqlSystemMetricsResponse, error) {
mysqlResp, err := tm.MysqlDaemon.SystemMetrics(ctx, tm.Cnf)
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 the bridge between TabletManager and MysqlDaemon. It is fully functional. But right now, no one will be calling this function, so there's no backwards-compatibility issue.

@shlomi-noach shlomi-noach added this to the v21.0.0 milestone Sep 26, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 41.23711% with 57 lines in your changes missing coverage. Please review.

Project coverage is 69.43%. Comparing base (766bc64) to head (757cada).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/mysqlctl/mysqld.go 68.29% 13 Missing ⚠️
go/vt/mysqlctl/fakemysqldaemon.go 0.00% 11 Missing ⚠️
go/vt/vttablet/grpctmclient/client.go 0.00% 9 Missing ⚠️
go/vt/vttablet/grpctmserver/server.go 0.00% 7 Missing ⚠️
go/vt/vttablet/tabletmanager/rpc_query.go 0.00% 7 Missing ⚠️
go/vt/mysqlctl/grpcmysqlctlserver/server.go 0.00% 2 Missing ⚠️
go/vt/vtcombo/tablet_map.go 0.00% 2 Missing ⚠️
go/vt/vttablet/faketmclient/fake_client.go 0.00% 2 Missing ⚠️
go/vt/vttablet/tabletserver/throttle/throttler.go 84.61% 2 Missing ⚠️
go/vt/vttablet/tmrpctest/test_tm_rpc.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16850   +/-   ##
=======================================
  Coverage   69.43%   69.43%           
=======================================
  Files        1571     1571           
  Lines      203086   203173   +87     
=======================================
+ Hits       141013   141079   +66     
- Misses      62073    62094   +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattlord mattlord self-assigned this Sep 26, 2024
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

LGTM! I only had some minor suggestions / questions. Let me know what you think and I'll come back to this quickly.

go/tools/releases/README.md Outdated Show resolved Hide resolved
proto/tabletmanagerdata.proto Outdated Show resolved Hide resolved
proto/mysqlctl.proto Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/rpc_query.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/mysqld.go Outdated Show resolved Hide resolved
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Thanks, @shlomi-noach ! ❤️

@shlomi-noach shlomi-noach merged commit 978c59d into vitessio:main Oct 1, 2024
101 checks passed
@shlomi-noach shlomi-noach deleted the throttler-mysql-metrics branch October 1, 2024 05:40
timvaillancourt pushed a commit to timvaillancourt/vitess that referenced this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Throttler Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants