-
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: ddl_strategy session variable and vtctl command line argument #7045
Online DDL: ddl_strategy session variable and vtctl command line argument #7045
Conversation
- no pre-generates primitives for normal DDL and Online DDL, wrapped in a new DDL primitive - DDL.Execute() chooses which of the underlying primitives to invoke Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ee if it's online or not Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
you can take the input as map in a separate session variable like |
Thank you. I'm thinnking two variables are difficult to maintain. The user will set one, and forget that the other one is already set from a previous cycle. I'm thinking to simplify as |
I am still unsure whether this approach of using session variables is any better for our users. Users want to be able to run exact same command on MySQL and on Vitess, such that the Vitess execution will run an online DDL. So, the |
go/vt/vtgate/engine/ddl.go
Outdated
|
||
//StreamExecute implements the Primitive interface | ||
func (v *DDL) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { | ||
return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable") // TODO: shlomi - have no idea if this should work |
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.
you can call Execute and pass the result in callback function. The plan is to merge Execute and StreamExecute with streaming only so we need to support then.
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.
Implemented
go/vt/vtgate/engine/ddl.go
Outdated
//GetFields implements the Primitive interface | ||
func (v *DDL) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error) { | ||
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable") // TODO: shlomi - have no idea if this should work | ||
} |
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.
this will not be called. todo can be removed.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…n-variable-use Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Currently there are 2 ways to execute DDL in Vitess.
|
There are few places that would need additional test
|
How would it look like in
How do you mean?
Yes, I was also thinking about that. One problem I have now is that, say we have a command line flag that sets to |
set @@ddl_strategy='gh-ost --max-load=Threads_running=100'; Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ts the default value for @@ddl_strategy 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 @@ddl_strategy session variable. Added unit and endtoend tests to support the new flag 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>
OK, this PR now supports:
set session ddl_strategy='gh-ost';
set @@ddl_strategy='gh-ost';
set @@ddl_strategy='gh-ost --max-load=Threads_running=100';
set @@ddl_strategy='';
select @@ddl_strategy;
A Followup PR will remove the Documentation to follow. |
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>
@harshit-gangal I've made changes since your last review; see #7045 (comment) |
func TestParseDDLStrategy(t *testing.T) { | ||
tt := []struct { | ||
strategyVariable string | ||
strategy sqlparser.DDLStrategy | ||
options string | ||
err error | ||
}{ |
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.
add an invalid parsing test.
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.
There is one, at the end of the function
go/vt/vtgate/engine/ddl.go
Outdated
|
||
var _ Primitive = (*DDL)(nil) | ||
|
||
//DDL represents the a DDL statement, either normal or online DDL |
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: convention in the code base is to have space between // and comment.
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/vtgate/vtgate.go
Outdated
@@ -60,6 +61,7 @@ var ( | |||
_ = flag.Bool("disable_local_gateway", false, "deprecated: if specified, this process will not route any queries to local tablets in the local cell") | |||
maxMemoryRows = flag.Int("max_memory_rows", 300000, "Maximum number of rows that will be held in memory for intermediate results as well as the final result.") | |||
warnMemoryRows = flag.Int("warn_memory_rows", 30000, "Warning threshold for in-memory results. A row count higher than this amount will cause the VtGateWarnings.ResultsExceeded counter to be incremented.") | |||
defaultDDLStrategy = flag.String("default-ddl-strategy", "", "Set default strategy for DDL statements. Override with @@ddl_strategy session variable") |
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 think we can drop the word default
from here. This is how some of the other startup parameters behave.
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
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.
Few nitpick comments. Everything else looks good to me.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Documentation: vitessio/website#598 |
Context: #6782 (comment)
Additional contexts: #6926, #6689
Extends #7042
In this PR we utilize the new
ddl_strategy
session variable. Consider the following:Thus, the choice whether to user "normal" DDL or Online DDL, can depend on the valud of
@@ddl_strategy
session variable, which is either:gh-ost
pt-osc
I'm not sure yet how to represent migration options. Would that be
set @@ddl_strategy='gh-ost; max-load=Threads_running=100'
? Seems quite the syntax.