Improve efficiency of vtorc topo calls #17071
Improve efficiency of vtorc topo calls #17071timvaillancourt merged 12 commits intovitessio:mainfrom
vtorc topo calls #17071Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
17e2786 to
e725df8
Compare
617f306 to
2afa448
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17071 +/- ##
==========================================
+ Coverage 67.17% 67.41% +0.23%
==========================================
Files 1571 1569 -2
Lines 252246 252171 -75
==========================================
+ Hits 169458 170002 +544
+ Misses 82788 82169 -619 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
c8095c0 to
f42dbcf
Compare
mattlord
left a comment
There was a problem hiding this comment.
This is looking good! ❤️ I only had some minor nits and suggestions. Let me know what you think.
GuptaManan100
left a comment
There was a problem hiding this comment.
Apart from Matt's comments, everything else LGTM. It can be merged once they have been addressed.
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
|
Thanks for the review! Updated with @mattlord's suggestions 👍 |
Co-authored-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
mattlord
left a comment
There was a problem hiding this comment.
Looking good! The only remaining issue is whether or not we want to support filtering by shard w/o a keyspace. I'm OK either way, but if we do want to support that then we should add a test case for it. That make sense?
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@mattlord I don't plan to support this because I can't think of a use case. I've updated to make keyspace required 👍 |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
|
Looks like the new unit test is flaky:
That's the only thing left! Thank you for sticking this out, @timvaillancourt ! This will be a nice improvement. |
|
Hmm, this flakiness is weird. Perhaps I need to sort the |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
|
@mattlord I believe moving |
There was a problem hiding this comment.
Great work on this, @timvaillancourt ! You can merge any time, just please don't forget to squash and merge.
One last note, up to you if you want to add it:
slices.SortFunc(out, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
for i, tablet := range out {
expected := tt.expectedTablets[i]
require.Equal(t, expected.Alias.String(), tablet.Alias.String())
require.Equal(t, expected.Keyspace, tablet.Keyspace)
require.Equal(t, expected.Shard, tablet.Shard)
}
Right now you're ordering all of the entries in expectedTablets by Uid in the test cases. IMO it's worth sorting that slice as well so that things do not become flaky in the future if someone modifies the existing test cases or adds new ones where that slice is not ordered:
slices.SortFunc(out, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
slices.SortFunc(tt.expectedTablets, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
for i, tablet := range out {
expected := tt.expectedTablets[i]
require.Equal(t, expected.Alias.String(), tablet.Alias.String())
require.Equal(t, expected.Keyspace, tablet.Keyspace)
require.Equal(t, expected.Shard, tablet.Shard)
}
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
|
@mattlord thanks for the reviews, added that! |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
* Move to native sqlite3 queries (vitessio#17124) Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Tim Vaillancourt <tim@timvaillancourt.com> * missing updates Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * fix % Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * missing comma Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Improve efficiency of `vtorc` topo calls (vitessio#17071) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com> --------- Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
* Move to native sqlite3 queries (vitessio#17124) Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Tim Vaillancourt <tim@timvaillancourt.com> * Improve efficiency of `vtorc` topo calls (vitessio#17071) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com> * Ensure all topo read calls consider `--topo_read_concurrency` (vitessio#17276) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Avoid flaky topo concurrency test (vitessio#17407) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * `vtorc`: fetch all tablets from cells once + filter during refresh (vitessio#17388) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Support KeyRange in `--clusters_to_watch` flag (vitessio#17604) Signed-off-by: Manan Gupta <manan@planetscale.com> * `vtorc`: improve handling of partial cell topo results (vitessio#17718) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Add stats for shards watched by VTOrc Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * add more tests Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * cleanup Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * fix ineffassign Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * fix test for v21 Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Use prefix in all vtorc check and recover logs (vitessio#17526) Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com> --------- Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Signed-off-by: Manan Gupta <manan@planetscale.com> Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com> Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Manan Gupta <35839558+GuptaManan100@users.noreply.github.com> Co-authored-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
Description
This PR adds a similar optimization to this PR to
vtorcby moving to usingts.GetTabletsByCell(...)and the newts.GetTabletsByShard(...)methods to fetch tablets. These methods respect the concurrency limit flag for the topo and seem to be more efficient overallSupport for filtering by keyspace/shard was added to
ts.GetTabletsByCell(...)which is called byts.GetTabletsByShard(...)Related to this discussion, we're unfortunately forced to fetch "all" records from the cell just to filter them out by keyspace/shard using
x != y. In our production when fetching topo records for a single shard, < 0.5% of the topo records fetched are actually used - but that's nothing newRelated Issue(s)
Resolves #17073
Checklist
Deployment Notes