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: remove legacy "stowaway table" logic #12288

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 1 addition & 37 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream) er
}

if !isVreplicationTestSuite {
// A bit early on, we generate names for stowaway and temporary tables
// A bit early on, we generate a name for the sentry table
// We do this here because right now we're in a safe place where nothing happened yet. If there's an error now, bail out
// and no harm done.
// Later on, when traffic is blocked and tables renamed, that's a more dangerous place to be in; we want as little logic
Expand Down Expand Up @@ -3509,30 +3509,6 @@ func (e *Executor) reviewRunningMigrations(ctx context.Context) (countRunnning i
postponeCompletion := row.AsBool("postpone_completion", false)
elapsedSeconds := row.AsInt64("elapsed_seconds", 0)

if stowawayTable := row.AsString("stowaway_table", ""); stowawayTable != "" {
// whoa
// stowawayTable is an original table stowed away while cutting over a vrepl migration, see call to cutOverVReplMigration() down below in this function.
// In a normal operation, the table should not exist outside the scope of cutOverVReplMigration
// If it exists, that means a tablet crashed while running a cut-over, and left the database in a bad state, where the migrated table does not exist.
// thankfully, we have tracked this situation and just realized what happened. Now, first thing to do is to restore the original table.
log.Infof("found stowaway table %s journal in migration %s for table %s", stowawayTable, uuid, onlineDDL.Table)
attemptMade, err := e.renameTableIfApplicable(ctx, stowawayTable, onlineDDL.Table)
if err != nil {
// unable to restore table; we bail out, and we will try again next round.
return countRunnning, cancellable, err
}
// success
if attemptMade {
log.Infof("stowaway table %s restored back into %s", stowawayTable, onlineDDL.Table)
} else {
log.Infof("stowaway table %s did not exist and there was no need to restore it", stowawayTable)
}
// OK good, table restored. We can remove the record.
if err := e.updateMigrationStowawayTable(ctx, uuid, ""); err != nil {
return countRunnning, cancellable, err
}
}

uuidsFoundRunning[uuid] = true

_ = e.updateMigrationUserThrottleRatio(ctx, uuid, currentUserThrottleRatio)
Expand Down Expand Up @@ -4327,18 +4303,6 @@ func (e *Executor) updateMigrationReadyToComplete(ctx context.Context, uuid stri
return nil
}

func (e *Executor) updateMigrationStowawayTable(ctx context.Context, uuid string, tableName string) error {
query, err := sqlparser.ParseAndBind(sqlUpdateMigrationStowawayTable,
sqltypes.StringBindVariable(tableName),
sqltypes.StringBindVariable(uuid),
)
if err != nil {
return err
}
_, err = e.execQuery(ctx, query)
return err
}

func (e *Executor) updateMigrationUserThrottleRatio(ctx context.Context, uuid string, ratio float64) error {
query, err := sqlparser.ParseAndBind(sqlUpdateMigrationUserThrottleRatio,
sqltypes.Float64BindVariable(ratio),
Expand Down
7 changes: 0 additions & 7 deletions go/vt/vttablet/onlineddl/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ const (
WHERE
migration_uuid=%a
`
sqlUpdateMigrationStowawayTable = `UPDATE _vt.schema_migrations
SET stowaway_table=%a
WHERE
migration_uuid=%a
`
sqlUpdateMigrationUserThrottleRatio = `UPDATE _vt.schema_migrations
SET user_throttle_ratio=%a
WHERE
Expand Down Expand Up @@ -278,7 +273,6 @@ const (
sqlSelectRunningMigrations = `SELECT
migration_uuid,
postpone_completion,
stowaway_table,
timestampdiff(second, started_timestamp, now()) as elapsed_seconds
FROM _vt.schema_migrations
WHERE
Expand Down Expand Up @@ -382,7 +376,6 @@ const (
is_view,
ready_to_complete,
reverted_uuid,
stowaway_table,
rows_copied,
vitess_liveness_indicator,
user_throttle_ratio,
Expand Down