File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,12 @@ const (
393
393
AND cleanup_timestamp IS NULL
394
394
AND completed_timestamp IS NULL
395
395
`
396
+ sqlFixRequestedTimestamp = `UPDATE _vt.schema_migrations
397
+ SET
398
+ requested_timestamp = added_timestamp
399
+ WHERE
400
+ requested_timestamp < added_timestamp;
401
+ `
396
402
sqlSelectMigration = `SELECT
397
403
id,
398
404
migration_uuid,
@@ -612,6 +618,13 @@ var (
612
618
var ApplyDDL = []string {
613
619
sqlCreateSidecarDB ,
614
620
sqlCreateSchemaMigrationsTable ,
621
+ // Fixing a historical issue: past values of requested_timestamp could be '0000-00-00 00:00:00'.
622
+ // In turn, those cause `ERROR 1292 (22007): Incorrect datetime value` when attempting to
623
+ // make any DDL on the table.
624
+ // We trust added_timestamp to be non-zero (it defaults CURRENT_TIMESTAMP and never modified),
625
+ // and so we set requested_timestamp to that value.
626
+ // The query makes a full table scan, because neither column is indexed.
627
+ sqlFixRequestedTimestamp , // end of fix
615
628
alterSchemaMigrationsTableRetries ,
616
629
alterSchemaMigrationsTableTablet ,
617
630
alterSchemaMigrationsTableArtifacts ,
You can’t perform that action at this time.
0 commit comments