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: store cells in backend and periodically refresh #17726

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

timvaillancourt
Copy link
Contributor

@timvaillancourt timvaillancourt commented Feb 10, 2025

Description

This PR causes VTOrc to store a list of known cells in the backend and refresh them during the usual topo tick. This is called first by OpenTabletDiscovery(...) (via refreshAllInformation(...)) and later on a ticker loop (default every 15s). I think a small amount of drift in what cells are alive will be ok, for example if a shard refresh happens right after a cell is added/removed (cc @GuptaManan100?)

Today the list of cells is refreshed every time time refreshTabletsUsing(...) is called, which can be more frequent than the ticker interval

This should reduce global topo reads while adding some resilence if ts.GetKnownCells(...) fails temporarily

Related Issue(s)

#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

@timvaillancourt timvaillancourt added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VTorc Vitess Orchestrator integration labels Feb 10, 2025
Copy link
Contributor

vitess-bot bot commented Feb 10, 2025

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 Feb 10, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Feb 10, 2025
@timvaillancourt timvaillancourt 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 Feb 10, 2025
@timvaillancourt timvaillancourt self-assigned this Feb 10, 2025
@timvaillancourt timvaillancourt marked this pull request as ready for review February 10, 2025 02:20
@timvaillancourt timvaillancourt force-pushed the vtorc-fetch-cells-on-ticker branch from f02aca7 to 9f6620d Compare February 10, 2025 02:25
Copy link

codecov bot commented Feb 10, 2025

Codecov Report

Attention: Patch coverage is 22.58065% with 48 lines in your changes missing coverage. Please review.

Project coverage is 67.94%. Comparing base (10a6916) to head (6b77931).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtorc/logic/cell_discovery.go 0.00% 33 Missing ⚠️
go/vt/vtorc/logic/tablet_discovery.go 0.00% 11 Missing ⚠️
go/vt/vtorc/logic/vtorc.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17726      +/-   ##
==========================================
- Coverage   67.94%   67.94%   -0.01%     
==========================================
  Files        1586     1587       +1     
  Lines      255173   255218      +45     
==========================================
+ Hits       173389   173396       +7     
- Misses      81784    81822      +38     

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

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]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
@GuptaManan100
Copy link
Member

This change could potentially be unsafe! If the user adds a cell and a tablet in that cell and runs a PRS to promote it. VTOrc might not see this new primary at all if all of this happened in the 15 seconds when the cell was added. VTOrc would end up then running a ClusterHasNoPrimary recovery. While this itself may not be destructive, but its not the right thing to do. I know this is a pretty rare situation, but none-the-less possible. WDYT @deepthi?

@timvaillancourt
Copy link
Contributor Author

This change could potentially be unsafe! If the user adds a cell and a tablet in that cell and runs a PRS to promote it. VTOrc might not see this new primary at all if all of this happened in the 15 seconds when the cell was added. VTOrc would end up then running a ClusterHasNoPrimary recovery. While this itself may not be destructive, but its not the right thing to do. I know this is a pretty rare situation, but none-the-less possible. WDYT @deepthi?

@GuptaManan100 good point! Hmm, I'll have to think if there's a safe way around this. Or maybe staleness in cells cannot be accepted 🤔

@timvaillancourt
Copy link
Contributor Author

If the user adds a cell and a tablet in that cell and runs a PRS to promote it. VTOrc might not see this new primary at all if all of this happened in the 15 seconds when the cell was added.

@GuptaManan100 I remembered you are working on a watch model for the global topo records; would moving this approach to a watch model help here?

In theory there would still be a delay in responding to the watch connection update and updating the backend table. This would be likely < 100ms but you can't really put an SLA on it

And a question: is VTOrc expected to be deployed in every cell? I think "no", but perhaps requiring a VTOrc in every cell in advance of tablets coming up would help work around some of this concern? In our production we run VTOrc in "a majority" of cells, not all

@deepthi
Copy link
Member

deepthi commented Feb 12, 2025

@timvaillancourt I'm questioning the premise of this PR

Today the list of cells is refreshed every time time refreshTabletsUsing(...) is called, which can be more frequent than the ticker interval

Where are you seeing this? There are exactly two calls to refreshAllInformation, both originate in ContinuousDiscovery

	tabletTopoTick := OpenTabletDiscovery() // this eventually calls refreshAllInformation
        ...
		case <-tabletTopoTick:
			ctx, cancel := context.WithTimeout(context.Background(), config.GetTopoInformationRefreshDuration())
			if err := refreshAllInformation(ctx); err != nil {

So I'm failing to see how this can be called more frequently than the ticker interval.

To the second point

while adding some resilence if ts.GetKnownCells(...) fails temporarily

What is the resilience that is intended? If vtorc is unable to reach the global topo, it should error and not try to fix anything.

@timvaillancourt
Copy link
Contributor Author

Where are you seeing this? There are exactly two calls to refreshAllInformation, both originate in ContinuousDiscovery

@deepthi thanks for pointing this out, it appears I missed something when reading the code

When an individual shard does a refresh it calls refreshTabletsInKeyspaceShard (also wrapped by forceRefreshAllTabletsInShard). This calls a similar-but-different func to getAllTablets: ts.GetTabletsByShard(...). This func also calls List in a goroutine-per-cell model so I mixed them up

Now, ts.GetTabletsByShard(...) wraps ts.GetTabletsByShardCell(...) by passing nil for cells, which causes a global-cell read for all cells. So this is where a potentially high rate of duplicated global reads could happen I suppose, with a rate of N x concurrent recoveries

Now that I'm aware forced shard refreshes happen using a different path, I updated the code to use cells from the backend in this scenario as well to demonstrate

What is the resilience that is intended? If vtorc is unable to reach the global topo, it should error and not try to fix anything.

Ideally a temporary problem accessing the global topo wouldn't stop VTOrc from solving problems in existing cells, but my main goal is to reduce duplicated topo calls when several recoveries occur; resilience is more of a side effect

@timvaillancourt
Copy link
Contributor Author

Ideally a temporary problem accessing the global topo wouldn't stop VTOrc from solving problems in existing cells

EDIT: nevermind 🤦. We need global topo locks 🤔

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants