Skip to content

Commit

Permalink
update_method_backupShard
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Wang <[email protected]>
  • Loading branch information
Jun Wang committed Nov 24, 2023
1 parent 4eb6ee2 commit 0885dff
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"io"
"math/rand"
"net/http"
"path/filepath"
"runtime/debug"
Expand Down Expand Up @@ -430,9 +431,32 @@ func (s *VtctldServer) BackupShard(req *vtctldatapb.BackupShardRequest, stream v
span.Annotate("concurrency", req.Concurrency)
span.Annotate("incremental_from_pos", req.IncrementalFromPos)

tablets, stats, err := reparentutil.ShardReplicationStatuses(ctx, s.ts, s.tmc, req.Keyspace, req.Shard)
shardTablets, stats, err := reparentutil.ShardReplicationStatuses(ctx, s.ts, s.tmc, req.Keyspace, req.Shard)
// Shuffle shardTablets to avoid items in a fixed order
rand.Shuffle(len(shardTablets), func(i, j int) {
shardTablets[i], shardTablets[j] = shardTablets[j], shardTablets[i]
})

var tablets []*topo.TabletInfo
// Instead of return on err directly, count total errors and compare with len(stats)
if err != nil {
return err
nilStatIndex, errorCount := 0, 0
for i, stat := range stats {
if stat == nil {
// Possible of multiple errors but only catch the last error index in stats
nilStatIndex = i
errorCount++
}
}
// Only return err when errors on all vttablets
if errorCount == len(stats) {
return err
}
for i, shardTablet := range shardTablets {
if i != nilStatIndex {
tablets = append(tablets, shardTablet)
}
}
}

var (
Expand Down

0 comments on commit 0885dff

Please sign in to comment.