Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
138089: server: cleanup creation of storeids slice for span stats r=xinhaoz a=xinhaoz

The creation of the storeIDs slice should be done after iterating through range descriptors, not at the end of each iteration. This commit fixes a misplacement of this code block.

Epic: none

Release note: None

Co-authored-by: Xin Hao Zhang <[email protected]>
  • Loading branch information
craig[bot] and xinhaoz committed Dec 30, 2024
2 parents c2f5b7c + d67ee3c commit 13b3512
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/server/span_stats_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,16 @@ func (s *systemStatusServer) statsForSpan(
return nil, err
}
}
}

spanStats.StoreIDs = make([]roachpb.StoreID, 0, len(storeIDs))
for storeID := range storeIDs {
spanStats.StoreIDs = append(spanStats.StoreIDs, storeID)
}
sort.Slice(spanStats.StoreIDs, func(i, j int) bool {
return spanStats.StoreIDs[i] < spanStats.StoreIDs[j]
})

spanStats.StoreIDs = make([]roachpb.StoreID, 0, len(storeIDs))
for storeID := range storeIDs {
spanStats.StoreIDs = append(spanStats.StoreIDs, storeID)
}
sort.Slice(spanStats.StoreIDs, func(i, j int) bool {
return spanStats.StoreIDs[i] < spanStats.StoreIDs[j]
})

// If we still have some remaining ranges, request range stats for the current batch.
if len(fullyContainedKeysBatch) > 0 {
// Obtain stats for fully contained ranges via RangeStats.
Expand Down

0 comments on commit 13b3512

Please sign in to comment.