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

Bugfix/Backport to v15: Fix schema migrations requested_timestamp zero values #12263

Merged
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
13 changes: 13 additions & 0 deletions go/vt/vttablet/onlineddl/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ const (
AND cleanup_timestamp IS NULL
AND completed_timestamp IS NULL
`
sqlFixRequestedTimestamp = `UPDATE _vt.schema_migrations
SET
requested_timestamp = added_timestamp
WHERE
requested_timestamp < added_timestamp;
`
sqlSelectMigration = `SELECT
id,
migration_uuid,
Expand Down Expand Up @@ -612,6 +618,13 @@ var (
var ApplyDDL = []string{
sqlCreateSidecarDB,
sqlCreateSchemaMigrationsTable,
// Fixing a historical issue: past values of requested_timestamp could be '0000-00-00 00:00:00'.
// In turn, those cause `ERROR 1292 (22007): Incorrect datetime value` when attempting to
// make any DDL on the table.
// We trust added_timestamp to be non-zero (it defaults CURRENT_TIMESTAMP and never modified),
// and so we set requested_timestamp to that value.
// The query makes a full table scan, because neither column is indexed.
sqlFixRequestedTimestamp, // end of fix
alterSchemaMigrationsTableRetries,
alterSchemaMigrationsTableTablet,
alterSchemaMigrationsTableArtifacts,
Expand Down