-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improve Schema Engine's TablesWithSize80 query #17066
Open
mattlord
wants to merge
7
commits into
vitessio:main
Choose a base branch
from
planetscale:1000s_tables_perf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+9
−5
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This avoids the table scan on <temporary> stage from the query execution in the middle here: EXPLAIN: -> Filter: (`TABLE_NAME` like 'trb3%') (actual time=1030..1030 rows=1 loops=1) -> Table scan on <temporary> (actual time=1030..1030 rows=3005 loops=1) -> Aggregate using temporary table (actual time=1030..1030 rows=3005 loops=1) ... Signed-off-by: Matt Lord <[email protected]>
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
|
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
Oct 25, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17066 +/- ##
==========================================
- Coverage 67.16% 67.16% -0.01%
==========================================
Files 1571 1571
Lines 252093 252097 +4
==========================================
+ Hits 169314 169315 +1
- Misses 82779 82782 +3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Matt Lord <[email protected]>
mattlord
added
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Component: VReplication
Component: Query Serving
Component: Schema Tracker
Component: Online DDL
Online DDL (vitess/native/gh-ost/pt-osc)
and 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
Oct 25, 2024
mattlord
changed the title
Improve Schema engine's TablesWithSize80 query
Improve Schema Engine's TablesWithSize80 query
Oct 25, 2024
mattlord
requested review from
rohit-nayak-ps,
harshit-gangal and
systay
as code owners
October 25, 2024 03:16
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
systay
approved these changes
Oct 25, 2024
notfelineit
approved these changes
Oct 25, 2024
Signed-off-by: Matt Lord <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: Online DDL
Online DDL (vitess/native/gh-ost/pt-osc)
Component: Query Serving
Component: Schema Tracker
Component: VReplication
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
With only the query change the manual test in #17059 passes. The reason that this impacts the OnlineDDL cutover is because:
ApplySchema
RPC, which tells the schema engine to reload its cache at the end, which uses the noted slow query in step 2. This causes the schema engine's cache to be reloaded while holding the mutex.TABLE_MAP
event in order to build and cache the table plan, and blocks on eventually reading from the cache because the mutex is held in step 3So because the modified query is ~ 260x faster than the original — with the original taking about 13000ms and the new one about 50ms (see below) — we are able to update the schema cache and read the current tables schema for vreplication within the relatively default short timeout that OnlineDDL uses when waiting for vreplication to reach the position where the primary was.
Using the manual test from the issue again, we can compare the query times:
And it still works properly with partitioned tables:
With only the timeout related changes the manual test in #17059 ALSO passes. The reason being that we're able to get past our schema reload work and reach the desired position within the larger timeout (the query blocking us takes ~ 13 seconds).
So we have two fixes for the underlying issue that not only solves the OnlineDDL specific aspects but also makes Vitess much more efficient overall when there are thousands of tables.
Related Issue(s)
Checklist