@@ -605,6 +605,61 @@ func testScheduler(t *testing.T) {
605
605
})
606
606
})
607
607
608
+ t .Run ("Postpone completion ALTER with shards" , func (t * testing.T ) {
609
+ t1uuid = testOnlineDDLStatement (t , createParams (trivialAlterT1Statement , ddlStrategy + " --postpone-completion" , "vtgate" , "" , "" , true )) // skip wait
610
+
611
+ t .Run ("wait for t1 running" , func (t * testing.T ) {
612
+ status := onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t1uuid , normalWaitTime , schema .OnlineDDLStatusRunning )
613
+ fmt .Printf ("# Migration status (for debug purposes): <%s>\n " , status )
614
+ })
615
+
616
+ t .Run ("wait for ready_to_complete" , func (t * testing.T ) {
617
+ waitForReadyToComplete (t , t1uuid , true )
618
+ rs := onlineddl .ReadMigrations (t , & vtParams , t1uuid )
619
+ require .NotNil (t , rs )
620
+ for _ , row := range rs .Named ().Rows {
621
+ assert .True (t , row ["shadow_analyzed_timestamp" ].IsNull ())
622
+ }
623
+ })
624
+
625
+ t .Run ("check postpone_completion" , func (t * testing.T ) {
626
+ rs := onlineddl .ReadMigrations (t , & vtParams , t1uuid )
627
+ require .NotNil (t , rs )
628
+ for _ , row := range rs .Named ().Rows {
629
+ postponeCompletion := row .AsInt64 ("postpone_completion" , 0 )
630
+ assert .Equal (t , int64 (1 ), postponeCompletion )
631
+ }
632
+ })
633
+ t .Run ("complete with irrelevant shards" , func (t * testing.T ) {
634
+ onlineddl .CheckCompleteMigrationShards (t , & vtParams , shards , t1uuid , "x,y,z" , false )
635
+ // Added an artificial sleep here just to ensure we're not missing a would-be completion./
636
+ time .Sleep (2 * time .Second )
637
+ // Migration should still be in running state
638
+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t1uuid , schema .OnlineDDLStatusRunning )
639
+ // postpone_completion should still be set
640
+ rs := onlineddl .ReadMigrations (t , & vtParams , t1uuid )
641
+ require .NotNil (t , rs )
642
+ for _ , row := range rs .Named ().Rows {
643
+ postponeCompletion := row .AsInt64 ("postpone_completion" , 0 )
644
+ assert .Equal (t , int64 (1 ), postponeCompletion )
645
+ }
646
+ })
647
+ t .Run ("complete with relevant shards" , func (t * testing.T ) {
648
+ onlineddl .CheckCompleteMigrationShards (t , & vtParams , shards , t1uuid , "x, y, 1" , true )
649
+ status := onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t1uuid , normalWaitTime , schema .OnlineDDLStatusComplete , schema .OnlineDDLStatusFailed )
650
+ fmt .Printf ("# Migration status (for debug purposes): <%s>\n " , status )
651
+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t1uuid , schema .OnlineDDLStatusComplete )
652
+ })
653
+ t .Run ("check no postpone_completion" , func (t * testing.T ) {
654
+ rs := onlineddl .ReadMigrations (t , & vtParams , t1uuid )
655
+ require .NotNil (t , rs )
656
+ for _ , row := range rs .Named ().Rows {
657
+ postponeCompletion := row .AsInt64 ("postpone_completion" , 0 )
658
+ assert .Equal (t , int64 (0 ), postponeCompletion )
659
+ }
660
+ })
661
+ })
662
+
608
663
t .Run ("Delayed postpone completion ALTER" , func (t * testing.T ) {
609
664
onlineddl .ThrottleAllMigrations (t , & vtParams )
610
665
defer onlineddl .UnthrottleAllMigrations (t , & vtParams )
0 commit comments