Skip to content

Commit

Permalink
feat: verify all the tablets are reachable in PRS
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Jul 26, 2023
1 parent af0f1f4 commit ad08598
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions go/vt/vtctl/reparentutil/planned_reparenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ func (pr *PlannedReparenter) reparentShardLocked(
return err
}

err = pr.verifyAllTabletsReachable(ctx, tabletMap)
if err != nil {
return err
}

// Check invariants that PlannedReparentShard depends on.
if isNoop, err := pr.preflightChecks(ctx, ev, keyspace, shard, tabletMap, &opts); err != nil {
return err
Expand Down Expand Up @@ -713,3 +718,26 @@ func (pr *PlannedReparenter) reparentTablets(

return nil
}

func (pr *PlannedReparenter) verifyAllTabletsReachable(ctx context.Context, tabletMap map[string]*topo.TabletInfo) error {
// Create a cancellable context for the entire set of RPCs to verify reachability.
verifyCtx, verifyCancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)
defer verifyCancel()

var (
wg sync.WaitGroup
rec concurrency.AllErrorRecorder
)

for _, info := range tabletMap {
wg.Add(1)
go func(tablet *topodatapb.Tablet) {
defer wg.Done()
_, err := pr.tmc.PrimaryStatus(verifyCtx, tablet)
rec.RecordError(err)
}(info.Tablet)
}

wg.Wait()
return rec.Error()
}

0 comments on commit ad08598

Please sign in to comment.