зеркало из https://github.com/github/vitess-gh.git
Online DDL: ensure requested_timestamp isn't zero, before initializing table schema (#12263)
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This commit is contained in:
Родитель
cf41ae7edf
Коммит
ca73cabc44
|
@ -393,6 +393,12 @@ const (
|
||||||
AND cleanup_timestamp IS NULL
|
AND cleanup_timestamp IS NULL
|
||||||
AND completed_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
|
sqlSelectMigration = `SELECT
|
||||||
id,
|
id,
|
||||||
migration_uuid,
|
migration_uuid,
|
||||||
|
@ -612,6 +618,13 @@ var (
|
||||||
var ApplyDDL = []string{
|
var ApplyDDL = []string{
|
||||||
sqlCreateSidecarDB,
|
sqlCreateSidecarDB,
|
||||||
sqlCreateSchemaMigrationsTable,
|
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,
|
alterSchemaMigrationsTableRetries,
|
||||||
alterSchemaMigrationsTableTablet,
|
alterSchemaMigrationsTableTablet,
|
||||||
alterSchemaMigrationsTableArtifacts,
|
alterSchemaMigrationsTableArtifacts,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче