Skip to content

Commit c292491

Browse files
server: change sort order of local hot ranges to descending
Currently the hot ranges logging system expects that ranges are sorted in descending order, so that it can inspect the values from greatest to least ([link](https://github.com/cockroachdb/cockroach/blob/master/pkg/server/application_api/storage_inspection_test.go#L377)). This is not the case, as the system currently returns those values in ascending order. This is an issue because it affects the correctness of the hot ranges logging system. That system requires the ranges to be in descending order to make decisions on when to log or not. This affects the usability of our documentation ([link](https://www.cockroachlabs.com/docs/v25.3/detect-hotspots)). To fix this, we just reverse the comparison used for sorting at the local hot ranges collector. Epic: none Fixes: none Release note: none
1 parent e29b20f commit c292491

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

pkg/server/application_api/storage_inspection_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ func TestHotRanges2Response(t *testing.T) {
340340
defer leaktest.AfterTest(t)()
341341
defer log.Scope(t).Close(t)
342342

343-
skip.WithIssue(t, 146917)
344-
345343
srv := rangetestutils.StartServer(t)
346344
defer srv.Stopper().Stop(context.Background())
347345
ts := srv.ApplicationLayer()

pkg/server/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ func (s *systemStatusServer) localHotRanges(
30693069

30703070
// sort the slices by cpu
30713071
slices.SortFunc(resp.Ranges, func(a, b *serverpb.HotRangesResponseV2_HotRange) int {
3072-
return cmp.Compare(a.CPUTimePerSecond, b.CPUTimePerSecond)
3072+
return cmp.Compare(b.CPUTimePerSecond, a.CPUTimePerSecond)
30733073
})
30743074

30753075
// truncate the response if localLimit is set

0 commit comments

Comments
 (0)