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

Online DDL: do not update last_throttled_timestamp with zero value #16395

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type testcase struct {

var (
clusterInstance *cluster.LocalProcessCluster
primaryTablet *cluster.Vttablet
vtParams mysql.ConnParams
evaluatedMysqlParams *mysql.ConnParams

Expand Down Expand Up @@ -368,6 +369,9 @@ var (
truncateStatement = `
TRUNCATE TABLE stress_test
`
setSqlMode = `
set @@global.sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
`
)

const (
Expand All @@ -391,17 +395,13 @@ func nextOpOrder() int64 {
return opOrder
}

func getTablet() *cluster.Vttablet {
return clusterInstance.Keyspaces[0].Shards[0].Vttablets[0]
}

func mysqlParams() *mysql.ConnParams {
if evaluatedMysqlParams != nil {
return evaluatedMysqlParams
}
evaluatedMysqlParams = &mysql.ConnParams{
Uname: "vt_dba",
UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", getTablet().TabletUID), "/mysql.sock"),
UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", primaryTablet.TabletUID), "/mysql.sock"),
DbName: fmt.Sprintf("vt_%s", keyspaceName),
}
return evaluatedMysqlParams
Expand Down Expand Up @@ -486,7 +486,11 @@ func TestSchemaChange(t *testing.T) {

shards = clusterInstance.Keyspaces[0].Shards
require.Equal(t, 1, len(shards))
require.Equal(t, 1, len(shards[0].Vttablets))
primaryTablet = shards[0].Vttablets[0]

_, err := primaryTablet.VttabletProcess.QueryTablet(setSqlMode, keyspaceName, true)
require.NoError(t, err)
throttler.EnableLagThrottlerAndWaitForStatus(t, clusterInstance)

for _, testcase := range testCases {
Expand All @@ -500,7 +504,7 @@ func TestSchemaChange(t *testing.T) {
}
})
t.Run("create schema", func(t *testing.T) {
assert.Equal(t, 1, len(clusterInstance.Keyspaces[0].Shards))
assert.Len(t, shards, 1)
testWithInitialSchema(t)
})
t.Run("prepare table", func(t *testing.T) {
Expand Down Expand Up @@ -596,8 +600,8 @@ func testOnlineDDLStatement(t *testing.T, alterStatement string, ddlStrategy str

// checkTable checks the number of tables in the first two shards.
func checkTable(t *testing.T, showTableName string) {
for i := range clusterInstance.Keyspaces[0].Shards {
checkTablesCount(t, clusterInstance.Keyspaces[0].Shards[i].Vttablets[0], showTableName, 1)
for i := range shards {
checkTablesCount(t, shards[i].Vttablets[0], showTableName, 1)
}
}

Expand Down Expand Up @@ -626,8 +630,8 @@ func checkTablesCount(t *testing.T, tablet *cluster.Vttablet, showTableName stri

// checkMigratedTables checks the CREATE STATEMENT of a table after migration
func checkMigratedTable(t *testing.T, tableName, expectHint string) {
for i := range clusterInstance.Keyspaces[0].Shards {
createStatement := getCreateTableStatement(t, clusterInstance.Keyspaces[0].Shards[i].Vttablets[0], tableName)
for i := range shards {
createStatement := getCreateTableStatement(t, shards[i].Vttablets[0], tableName)
assert.Contains(t, createStatement, expectHint)
}
}
Expand Down
6 changes: 4 additions & 2 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3870,8 +3870,10 @@ func (e *Executor) reviewRunningMigrations(ctx context.Context) (countRunnning i
_ = e.updateRowsCopied(ctx, uuid, s.rowsCopied)
_ = e.updateMigrationProgressByRowsCopied(ctx, uuid, s.rowsCopied)
_ = e.updateMigrationETASecondsByProgress(ctx, uuid)
_ = e.updateMigrationLastThrottled(ctx, uuid, time.Unix(s.timeThrottled, 0), s.componentThrottled)

if s.timeThrottled != 0 {
// Avoid creating a 0000-00-00 00:00:00 timestamp
_ = e.updateMigrationLastThrottled(ctx, uuid, time.Unix(s.timeThrottled, 0), s.componentThrottled)
}
if onlineDDL.StrategySetting().IsInOrderCompletion() {
// We will fail an in-order migration if there's _prior_ migrations within the same migration-context
// which have failed.
Expand Down
Loading