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

vtorc: fetch shard names only every --topo-information-refresh-duration #17319

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

timvaillancourt
Copy link
Contributor

@timvaillancourt timvaillancourt commented Dec 2, 2024

Description

This PR causes VTOrc to fetch+cache the list of shard names it is watching when --clusters_to_watch is defined, at an interval of --topo-information-refresh-duration (default 15s). When --clusters_to_watch is undef this change has no impact. The goal of this is to reduce calls to the topo and to respect the topo refresh duration flag

This was achieved by storing the shard names when they're already fetched at the desired interval by the existent RefreshAllKeyspacesAndShards(...) func, and allowing it to be read under lock. While I was there I added a gauge for the keyspace/shard combos watched by VTOrc, as previously discussed in #feat-vtorc in the Vitess Slack

Today a list of shard names is fetched for every "refresh" action in go/vt/vtorc/logic/tablet_discovery.go, which is potentially called concurrently and more frequently than the --topo-information-refresh-duration

Related Issue(s)

Tracking issue: #17330

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 Dec 2, 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 Dec 2, 2024
@github-actions github-actions bot added this to the v22.0.0 milestone Dec 2, 2024
@timvaillancourt timvaillancourt added Type: Enhancement Logical improvement (somewhere between a bug and feature) Type: Performance Component: VTorc Vitess Orchestrator integration and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Dec 2, 2024
defer keyspaceShardNamesMu.Unlock()
return keyspaceShardNames[keyspaceName]
}

// RefreshAllKeyspacesAndShards reloads the keyspace and shard information for the keyspaces that vtorc is concerned with.
func RefreshAllKeyspacesAndShards() {
Copy link
Contributor Author

@timvaillancourt timvaillancourt Dec 2, 2024

Choose a reason for hiding this comment

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

This func is called by a ticker-loop in vtorc.go with a duration == to --topo-information-refresh-duration

It is also called before the ticker loop begins

@timvaillancourt timvaillancourt marked this pull request as ready for review December 2, 2024 21:53
@deepthi
Copy link
Member

deepthi commented Dec 2, 2024

You might want to create a blanket "vtorc performance improvements" issue so that you can link multiple PRs to that same issue.

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 61.22449% with 38 lines in your changes missing coverage. Please review.

Project coverage is 67.53%. Comparing base (45192d2) to head (0221904).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtorc/logic/keyspace_shard_discovery.go 0.00% 36 Missing ⚠️
go/vt/vtorc/logic/tablet_discovery.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17319   +/-   ##
=======================================
  Coverage   67.52%   67.53%           
=======================================
  Files        1581     1581           
  Lines      253948   253991   +43     
=======================================
+ Hits       171480   171522   +42     
- Misses      82468    82469    +1     

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

@timvaillancourt timvaillancourt force-pushed the vtorc-store-parsed-clustersToWatch branch from 22482c3 to d5456a2 Compare December 3, 2024 01:21
Signed-off-by: Tim Vaillancourt <[email protected]>
@timvaillancourt
Copy link
Contributor Author

You might want to create a blanket "vtorc performance improvements" issue so that you can link multiple PRs to that same issue.

@deepthi good idea, I've summarized the efforts here: #17330 👍

@timvaillancourt timvaillancourt removed the NeedsIssue A linked issue is missing for this Pull Request label Dec 3, 2024
@timvaillancourt timvaillancourt self-assigned this Dec 3, 2024
@GuptaManan100
Copy link
Member

I like the change, but I would implement it slightly differently. VTOrc maintains its state in a database, and this change feels like an anti-pattern. I would rather store this new information about shards to watch in a database table too. What do you think @timvaillancourt @deepthi?

@deepthi
Copy link
Member

deepthi commented Dec 9, 2024

I like the change, but I would implement it slightly differently. VTOrc maintains its state in a database, and this change feels like an anti-pattern. I would rather store this new information about shards to watch in a database table too. What do you think @timvaillancourt @deepthi?

That's a good point. @timvaillancourt can you make that change?

@timvaillancourt
Copy link
Contributor Author

@GuptaManan100 / @deepthi i see your point, yes I can make this a query to a sqlite3 table 👍

Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
return err
}
}
lastAllKeyspaceShardsRefreshTime = time.Now()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated without mutex because this isn't called concurrently

Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
@timvaillancourt timvaillancourt marked this pull request as draft December 20, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VTorc Vitess Orchestrator integration Type: Enhancement Logical improvement (somewhere between a bug and feature) Type: Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants