-
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
Online DDL plan via Send; "singleton" migrations on tablets #7785
Online DDL plan via Send; "singleton" migrations on tablets #7785
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ne-ddl-send-plan-comments Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
- introducing DDLStrategySetting, formal wrapper for strategy+options - NewOnlineDDLs generates multiple OnlineDDL from a given statement, instead of parser generating multiple statements - OnlineDDL utilizes DDLStrategySetting; some logic moved out from OnlineDDL and into DDLStrategySetting Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…mal; also uses NewOnlineDDLs to break down queries Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…to clean up VT comments from query Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
… instead of writing them to topo. It utilizes new DDLStrategySetting, and uses samd TaretDestination as non-online DDL engine. Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…SQL string, but validates that it parses as a DDLStatement Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…eDDL now parses query and expects either DDLStatement or RevertMigration Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…rt statement on IsSkipTopo() Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ntial quotes and spaces in text. OnlineDDLFromCommentedStatement() function reads a commented statement and reconstructs an OnlineDDL instance Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from what I can see. Mostly looked over parser, engine and both planners
go/vt/schema/ddl_strategy.go
Outdated
@@ -0,0 +1,156 @@ | |||
/* | |||
Copyright 2019 The Vitess Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
go/vt/schema/ddl_strategy_test.go
Outdated
@@ -0,0 +1,109 @@ | |||
/* | |||
Copyright 2019 The Vitess Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
go/vt/schema/online_ddl.go
Outdated
} | ||
} | ||
return onlineDDLs, nil | ||
case *sqlparser.CreateTable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of adding a comment that this is done later, why not just do it in here straight away? just to keep the logic easier to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean, but there is code that is shard to all DropTable
, CreateTable
, AlterTable
that is performed after the switch
statement, when DropTable
has, on top, special handling. I've clarified that in code comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored. It does look better now
go/vt/schema/online_ddl.go
Outdated
case *sqlparser.AlterTable: | ||
// handled later on | ||
default: | ||
return nil, fmt.Errorf("Unsupported statement for Online DDL: %v", sqlparser.String(ddlStmt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:vterrors
is your friend. this applies to quite a few errors in this file.
also, I believe errors should not start with a capitalised letter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced all fmt.Errorf()
in this file with vterrors
, lower case as needed.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
Two in one!
This PR introduces (WIP) "singleton migrations": a setting where you can't submit a new migration if any of the relevant shards still has any other pending migration (
queued
,ready
, running`).The use case resurfaced the question of the use of
topo
in Online DDL. And I'm using the particular use case to begin the refactor away fromtopo
.Elaborating on the refactor, first:
Online DDL is still the only mechanism that utilizes
topo
as a mean to communicate fromVTGate
orvtctl
tovttablets
. There's advantages to going throughtopo
(decoupling, persisted "request" entry, auto-retries), but there's also disadvantages: too decoupled, non-idiomatic path, added constraint onvtctld
availability.With the recent introduction of migration queries, #7663 , #7656 , I see a nice path out of
topo
and into more fine-grained control over migrations.The changes offered here provide 1-version backwards compatibility, and for now require opting-in.
How will the new online DDL plan/engine flow work?
For some DDL queries (where the user intentionally opted-in), we create a
Send
engine primitive, just as we would for direct DDLs. We decorate the DDL query with online DDL hints. For example, assuming ourddl_strategy
isonline
, the query:is decorated as follows:
alter /*vt+ uuid="38ea1d8d_95da_11eb_b1fa_f875a4d24e90" context="vtctl:38be36cc-95da-11eb-b1fa-f875a4d24e90" strategy="online" options="" */ table corder engine innodb
and sent via
Send
. The tablet planner (TODO) will intercept the query and realize there's online DDL hints, and that's how it will know that the query should run viaonlineddl.Executor
rather than a direct commit on the backend database.About singleton migrations
To be implemented; the refactor came first. The user will use
-singleton
strategy flag, e.g.:or
The query will return with UUID if no other pending migration exists on relevant shards, and will atomically fail if there's at least one shard with a pending migration.
This is not implemented yet; I will implement this using a timeout-based mechanism, to avoid overly complex two-phase-commit logic. There may be some constraints on the user (e.g. if one migration is
-singleton
then all others must also be-singleton
or else behavior is undefined).Notes to the reviewer
There's many files affected here, but most are just affected by the initial refactor (e.g. change of function signature). The main changes right now are:
go/vt/sqlparser
: allCREATE
,DROP
,ALTER
statements now supportcomment_opt
.CREATE TABLE
,DROP TABLE
,ALTER TABLE
, butyacc
doesn't like it.DDLStatement
now hasSetComments()
function which allows the us to inject comments into a statement.go/vt/schema
:DDLStrategySetting
, which is a formal representation of theddl_strategy
value; some logic moved outside ofonline_ddl.go
and intoddl_strategy.go
.OnlineDDL
instance now uses saidDDLStrategySetting
.NewOnlineDDLs
function: refactorparser.go
logic into a more formal breakdown of a ddl statementNewOnlineDDL
function chooses whether to decorate the SQL query with/*vt+ ... */
hintsgo/vt/vtgate
:engine/online_ddl.go
:OnlineDDL
primitive now chooses whether to write OnlineDDL request to topo, or to submit directly to tablets viaSend
revert_migration.go
Most other changes (e.g.
schemamanager
) are just by-product of the introduction ofDDLStrategySetting
, and I'm happy to say the refactor formalized and I think simplified a bit, the logic in those places.Related Issue(s)
Checklist
Deployment Notes
Impacted Areas in Vitess
Components that this PR will affect: