-
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=direct #7172
Merged
shlomi-noach
merged 8 commits into
vitessio:master
from
planetscale:ddl-strategy-direct
Dec 22, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f3dcaab
Online DDL: ddl_strategy=direct
shlomi-noach b65173c
Merge remote-tracking branch 'upstream/master' into ddl-strategy-direct
shlomi-noach d658771
merge master
shlomi-noach 6ef298a
Merge remote-tracking branch 'upstream/master' into ddl-strategy-direct
shlomi-noach ea5284a
restoring 'Received DDL request. strategy=' log message
shlomi-noach d0be367
onlineddl: init schema upon VExec request, which may come sooner than…
shlomi-noach 526b741
reduce online ddl endtoend -migration_check_interval
shlomi-noach 5940f30
fixed online ddl endtoend tests: need to parse strategy, or else it w…
shlomi-noach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,16 +152,16 @@ func (exec *TabletExecutor) parseDDLs(sqls []string) ([]sqlparser.DDLStatement, | |
return parsedDDLs, parsedDBDDLs, nil | ||
} | ||
|
||
// IsOnlineSchemaDDL returns true if the query is an online schema change DDL | ||
func (exec *TabletExecutor) isOnlineSchemaDDL(ddl sqlparser.DDLStatement) (isOnline bool, strategy schema.DDLStrategy, options string) { | ||
if ddl == nil { | ||
// IsOnlineSchemaDDL returns true if we expect to run a online schema change DDL | ||
func (exec *TabletExecutor) isOnlineSchemaDDL() (isOnline bool, strategy schema.DDLStrategy, options string) { | ||
strategy, options, err := schema.ParseDDLStrategy(exec.ddlStrategy) | ||
if err != nil { | ||
return false, strategy, options | ||
} | ||
strategy, options, _ = schema.ParseDDLStrategy(exec.ddlStrategy) | ||
if strategy != schema.DDLStrategyNormal { | ||
return true, strategy, options | ||
if strategy.IsDirect() { | ||
return false, strategy, options | ||
} | ||
return false, strategy, options | ||
return true, strategy, options | ||
} | ||
|
||
// a schema change that satisfies any following condition is considered | ||
|
@@ -183,7 +183,7 @@ func (exec *TabletExecutor) detectBigSchemaChanges(ctx context.Context, parsedDD | |
tableWithCount[tableSchema.Name] = tableSchema.RowCount | ||
} | ||
for _, ddl := range parsedDDLs { | ||
if isOnline, _, _ := exec.isOnlineSchemaDDL(ddl); isOnline { | ||
if isOnline, _, _ := exec.isOnlineSchemaDDL(); isOnline { | ||
// Since this is an online schema change, there is no need to worry about big changes | ||
continue | ||
} | ||
|
@@ -218,10 +218,10 @@ func (exec *TabletExecutor) executeSQL(ctx context.Context, sql string, execResu | |
if err != nil { | ||
return err | ||
} | ||
switch ddl := stat.(type) { | ||
switch stat.(type) { | ||
case sqlparser.DDLStatement: | ||
if isOnlineDDL, strategy, options := exec.isOnlineSchemaDDL(ddl); isOnlineDDL { | ||
exec.wr.Logger().Infof("Received online DDL request. strategy=%+v", strategy) | ||
if isOnlineDDL, strategy, options := exec.isOnlineSchemaDDL(); isOnlineDDL { | ||
exec.wr.Logger().Infof("Received DDL request. strategy=%+v", strategy) | ||
normalizedQueries, err := schema.NormalizeOnlineDDL(sql) | ||
if err != nil { | ||
return err | ||
|
@@ -232,6 +232,7 @@ func (exec *TabletExecutor) executeSQL(ctx context.Context, sql string, execResu | |
return nil | ||
} | ||
} | ||
exec.wr.Logger().Infof("Received DDL request. strategy=%+v", schema.DDLStrategyDirect) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it is useful to log the |
||
exec.executeOnAllTablets(ctx, execResult, sql) | ||
return nil | ||
} | ||
|
@@ -276,7 +277,6 @@ func (exec *TabletExecutor) Execute(ctx context.Context, sqls []string) *Execute | |
execResult.ExecutorErr = err.Error() | ||
return &execResult | ||
} | ||
|
||
if len(execResult.FailedShards) > 0 { | ||
break | ||
} | ||
|
@@ -289,7 +289,7 @@ func (exec *TabletExecutor) executeOnlineDDL( | |
ctx context.Context, execResult *ExecuteResult, sql string, | ||
tableName string, strategy schema.DDLStrategy, options string, | ||
) { | ||
if strategy == schema.DDLStrategyNormal { | ||
if strategy.IsDirect() { | ||
execResult.ExecutorErr = "Not an online DDL strategy" | ||
return | ||
} | ||
|
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 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 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 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 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
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.
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 pick:
explciitly