diff --git a/go/vt/schema/ddl_strategy_test.go b/go/vt/schema/ddl_strategy_test.go index f27f0963e80..c394907b98a 100644 --- a/go/vt/schema/ddl_strategy_test.go +++ b/go/vt/schema/ddl_strategy_test.go @@ -328,6 +328,13 @@ func TestParseDDLStrategy(t *testing.T) { runtimeOptions: "", forceCutOverAfter: 3 * time.Minute, }, + { + strategyVariable: "vitess --force-cut-over-after=-1ms", + strategy: DDLStrategyVitess, + options: "--force-cut-over-after=-1ms", + runtimeOptions: "", + forceCutOverAfter: -1 * time.Millisecond, + }, { strategyVariable: "vitess --force-cut-over-after=r3m", strategy: DDLStrategyVitess, diff --git a/go/vt/vttablet/onlineddl/executor.go b/go/vt/vttablet/onlineddl/executor.go index db73f67ed64..a432581b3cd 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -3845,7 +3845,7 @@ func (e *Executor) reviewRunningMigrations(ctx context.Context) (countRunnning i uuid := row["migration_uuid"].ToString() cutoverAttempts := row.AsInt64("cutover_attempts", 0) sinceLastCutoverAttempt := time.Second * time.Duration(row.AsInt64("seconds_since_last_cutover_attempt", 0)) - sinceReadyToComplete := time.Second * time.Duration(row.AsInt64("seconds_since_ready_to_complete", 0)) + sinceReadyToComplete := time.Microsecond * time.Duration(row.AsInt64("microseconds_since_ready_to_complete", 0)) onlineDDL, migrationRow, err := e.readMigration(ctx, uuid) if err != nil { return countRunnning, cancellable, err diff --git a/go/vt/vttablet/onlineddl/executor_test.go b/go/vt/vttablet/onlineddl/executor_test.go index 1dc5447bbb9..d5e7f635a19 100644 --- a/go/vt/vttablet/onlineddl/executor_test.go +++ b/go/vt/vttablet/onlineddl/executor_test.go @@ -481,6 +481,38 @@ func TestShouldCutOverAccordingToBackoff(t *testing.T) { expectShouldCutOver: false, expectShouldForceCutOver: false, }, + { + name: "zero since ready", + cutoverAttempts: 3, + forceCutOverAfter: time.Second, + sinceReadyToComplete: 0, + expectShouldCutOver: false, + expectShouldForceCutOver: false, + }, + { + name: "zero since read, zero cut-over-after", + cutoverAttempts: 3, + forceCutOverAfter: 0, + sinceReadyToComplete: 0, + expectShouldCutOver: false, + expectShouldForceCutOver: false, + }, + { + name: "microsecond", + cutoverAttempts: 3, + forceCutOverAfter: time.Microsecond, + sinceReadyToComplete: time.Millisecond, + expectShouldCutOver: true, + expectShouldForceCutOver: true, + }, + { + name: "microsecond, not ready", + cutoverAttempts: 3, + forceCutOverAfter: time.Millisecond, + sinceReadyToComplete: time.Microsecond, + expectShouldCutOver: false, + expectShouldForceCutOver: false, + }, { name: "cutover-after overrides backoff", cutoverAttempts: 3, diff --git a/go/vt/vttablet/onlineddl/schema.go b/go/vt/vttablet/onlineddl/schema.go index 28e32e7dab4..c4c26aa52fd 100644 --- a/go/vt/vttablet/onlineddl/schema.go +++ b/go/vt/vttablet/onlineddl/schema.go @@ -304,7 +304,7 @@ const ( postpone_completion, force_cutover, cutover_attempts, - ifnull(timestampdiff(second, ready_to_complete_timestamp, now()), 0) as seconds_since_ready_to_complete, + ifnull(timestampdiff(microsecond, ready_to_complete_timestamp, now(6)), 0) as microseconds_since_ready_to_complete, ifnull(timestampdiff(second, last_cutover_attempt_timestamp, now()), 0) as seconds_since_last_cutover_attempt, timestampdiff(second, started_timestamp, now()) as elapsed_seconds FROM _vt.schema_migrations