Skip to content

Commit 88ce82c

Browse files
yushuqinClaude
andcommitted
fix: scope OnlineDDL filter to initial read only
Move the stopped-OnlineDDL filter behind a parameter so it only applies during the initial full read in readSourceStreams. Re-reads by ID (after stopSourceStreams) no longer skip stopped OnlineDDL, preventing running OnlineDDL workflows from being dropped mid-migration. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent f64d905 commit 88ce82c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

go/vt/vtctl/workflow/stream_migrator.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (sm *StreamMigrator) legacyReadTabletStreams(ctx context.Context, ti *topo.
372372

373373
// readTabletStreams reads all of the VReplication workflow streams *except*
374374
// the Reshard workflow's reverse variant.
375-
func (sm *StreamMigrator) readTabletStreams(ctx context.Context, ti *topo.TabletInfo, ids []int32, states []binlogdatapb.VReplicationWorkflowState, excludeFrozen bool) ([]*VReplicationStream, error) {
375+
func (sm *StreamMigrator) readTabletStreams(ctx context.Context, ti *topo.TabletInfo, ids []int32, states []binlogdatapb.VReplicationWorkflowState, excludeFrozen bool, excludeStoppedOnlineDDL bool) ([]*VReplicationStream, error) {
376376
req := &tabletmanagerdatapb.ReadVReplicationWorkflowsRequest{
377377
ExcludeWorkflows: []string{sm.ts.ReverseWorkflowName()},
378378
IncludeIds: ids,
@@ -398,7 +398,8 @@ func (sm *StreamMigrator) readTabletStreams(ctx context.Context, ti *topo.Tablet
398398
}
399399

400400
for _, stream := range workflow.Streams {
401-
if workflow.WorkflowType == binlogdatapb.VReplicationWorkflowType_OnlineDDL &&
401+
if excludeStoppedOnlineDDL &&
402+
workflow.WorkflowType == binlogdatapb.VReplicationWorkflowType_OnlineDDL &&
402403
stream.State == binlogdatapb.VReplicationWorkflowState_Stopped {
403404
continue
404405
}
@@ -562,7 +563,7 @@ func (sm *StreamMigrator) readSourceStreams(ctx context.Context, cancelMigrate b
562563
// This allows us to assume that all stopped streams can be safely restarted
563564
// if we cancel the operation.
564565
stoppedStreams, err := sm.readTabletStreams(ctx, source.GetPrimary(), nil,
565-
[]binlogdatapb.VReplicationWorkflowState{binlogdatapb.VReplicationWorkflowState_Stopped}, true)
566+
[]binlogdatapb.VReplicationWorkflowState{binlogdatapb.VReplicationWorkflowState_Stopped}, true, false)
566567
if err != nil {
567568
return err
568569
}
@@ -574,7 +575,7 @@ func (sm *StreamMigrator) readSourceStreams(ctx context.Context, cancelMigrate b
574575
}
575576
}
576577

577-
tabletStreams, err := sm.readTabletStreams(ctx, source.GetPrimary(), nil, nil, false)
578+
tabletStreams, err := sm.readTabletStreams(ctx, source.GetPrimary(), nil, nil, false, true)
578579
if err != nil {
579580
return err
580581
}
@@ -759,7 +760,7 @@ func (sm *StreamMigrator) stopSourceStreams(ctx context.Context) error {
759760
return err
760761
}
761762

762-
tabletStreams, err = sm.readTabletStreams(ctx, source.GetPrimary(), VReplicationStreams(tabletStreams).IDs(), nil, false)
763+
tabletStreams, err = sm.readTabletStreams(ctx, source.GetPrimary(), VReplicationStreams(tabletStreams).IDs(), nil, false, false)
763764
if err != nil {
764765
return err
765766
}
@@ -933,7 +934,7 @@ func (sm *StreamMigrator) verifyStreamPositions(ctx context.Context, stopPositio
933934
return nil
934935
}
935936

936-
tabletStreams, err := sm.readTabletStreams(ctx, source.GetPrimary(), VReplicationStreams(tabletStreams).IDs(), nil, false)
937+
tabletStreams, err := sm.readTabletStreams(ctx, source.GetPrimary(), VReplicationStreams(tabletStreams).IDs(), nil, false, false)
937938
if err != nil {
938939
return err
939940
}

0 commit comments

Comments
 (0)