vttablet sidecar schema:use schemadiff to reach desired schema on tablet init replacing the withDDL-based approach#11520
Merged
rohit-nayak-ps merged 15 commits intovitessio:mainfrom Feb 1, 2023
Conversation
Contributor
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
3 tasks
0bd5572 to
2bbae28
Compare
7cd38bd to
27a206f
Compare
d33a2f9 to
a761961
Compare
ba61177 to
cd581e0
Compare
348d0b1 to
dd7865d
Compare
1d2fef9 to
ca49239
Compare
rohit-nayak-ps
commented
Jan 12, 2023
rohit-nayak-ps
commented
Jan 12, 2023
Member
Author
There was a problem hiding this comment.
This test is no longer valid after the change in how we initialize _vt.
Collaborator
There was a problem hiding this comment.
As a nice bonus, we no longer have to worry about this test being flaky (which it has been in the past).
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
…e to get rid of the comments and make related changes to tests Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
dbussink
reviewed
Feb 1, 2023
|
|
||
| CREATE TABLE IF NOT EXISTS _vt.vdiff | ||
| ( | ||
| `id` bigint(20) NOT NULL AUTO_INCREMENT, |
Member
There was a problem hiding this comment.
@rohit-nayak-ps For a separate follow up PR, but I think we should drop lengths for bigint and other int types, since that is deprecated and on MySQL 8.0 doesn't do anything.
Contributor
There was a problem hiding this comment.
👍 and also worth mentioning that schemadiff ignores the length values (unless it's 1), so whether they exist or not, does not make any change to prod.
3 tasks
5 tasks
3 tasks
3 tasks
3 tasks
3 tasks
This was referenced Feb 22, 2023
4 tasks
Merged
4 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR changes the way we maintain the
_vtschema. Instead of usingwithddlintroduced in #6348 we use a declarative approach. This is made possible byschemadiffwhich is used in Online DDL's declarative strategy.The desired schema is specified, one per table. A new module
sidecardb, compares this to the existing schema and performs the required create or alter to reach it. This is done on the primary, on every vttablet startup.An intended side-effect of this PR is to be able to minimize the time window, on a replica, where the database is NOT in super-read-only mode.
The sidecar tables
local_metadataandshard_metadataare no longer in use and all references to them are removed in this PR. There were used previously forOrchestratorsupport, which has been superseded byvtorcNotes
Replicas cannot be started with super-read-only on
We cannot start a replica with super-read-only on since we have a bootstrap problem: vttablet needs to connect to its mysql instance to manage it. For that it needs to user credentials. To create user credentials we first need to create the users. This is done by executing the queries in
init_db.sql, when the database is first created.Also until a primary is selected we don't know if the current vttablet is going to be a replica or not. If it becomes a primary then it will insert a row into
reparent_journalfor the other replicas to move forward as replicas.Implementation Notes
Working Notes related to implementation, todos and misc notes, in no particular order, to be appropriately folded into the main description before completion.
go/vt/vttablet/tabletserver/schema/engine.go
The schema creation/updation is done in
EnsureConnectionAndDB(), both for replicas and primaryconfig/init_db.sql
Incidental flaky test fixes
Implementation Todos
DemotePrimary()
_vt, during first tablet loadMinor:
Related Issue(s)
#10133
Previous related PRs
These were created previously and closed since those didn't work well.
#11235
Checklist
Follow-up todos after the initial merge
Docs
_vtschema updats (update/extend theLife of a clusterdoc)