Skip to content
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

ApplySchema --batch-size fails with --allow-zero-in-date strategy flag #13950

Closed
shlomi-noach opened this issue Sep 11, 2023 · 0 comments · Fixed by #13951
Closed

ApplySchema --batch-size fails with --allow-zero-in-date strategy flag #13950

shlomi-noach opened this issue Sep 11, 2023 · 0 comments · Fixed by #13951
Assignees
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Component: vtctl Type: Bug

Comments

@shlomi-noach
Copy link
Contributor

#13693 introduced a --batch-size flag, to be used with CREATE statements only and with direct ddl strategy.

When the ddl strategy includes --allow-zero-in-date, ApplySchema --batch-size <greater_than_1> fails; this happens because TabletExecutor attempts to inject query modifiers (specifically /*vt+ allowZeroInDate=true */) into the SQL query. This is the relevant code:

if exec.ddlStrategySetting != nil && exec.ddlStrategySetting.IsAllowZeroInDateFlag() {
// --allow-zero-in-date Applies to DDLs
stmt, err := sqlparser.Parse(string(sql))
if err != nil {
errChan <- ShardWithError{Shard: tablet.Shard, Err: err.Error()}
return
}
if ddlStmt, ok := stmt.(sqlparser.DDLStatement); ok {
// Add comments directive to allow zero in date
const directive = `/*vt+ allowZeroInDate=true */`
ddlStmt.SetComments(ddlStmt.GetParsedComments().Prepend(directive))
sql = sqlparser.String(ddlStmt)
}
}

Problem is that with --batch-size the SQL can contain multiple queries.

The bug was not caught because it only happens when --allow-zero-in-date is added, which wasn't tested in #13693's tests.

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: vtctl Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant