Skip to content

Commit 114a87b

Browse files
committed
sql/stats: remove extended sentry reporting for an error
This commit reverts 85500f0. I think we fixed the root cause of the "first bucket should have NumRange=0" in 10a2ffe, so we no longer need the extended sentry reporting (which also didn't quite work in all cases). Release note: None
1 parent 3647a54 commit 114a87b

File tree

2 files changed

+0
-63
lines changed

2 files changed

+0
-63
lines changed

pkg/sql/stats/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ go_library(
5757
"//pkg/util/log",
5858
"//pkg/util/mon",
5959
"//pkg/util/protoutil",
60-
"//pkg/util/sentryutil",
6160
"//pkg/util/stop",
6261
"//pkg/util/syncutil",
6362
"//pkg/util/timeutil",

pkg/sql/stats/forecast.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,17 @@ package stats
77

88
import (
99
"context"
10-
"crypto/md5"
11-
"encoding/json"
12-
"fmt"
1310
"math"
1411
"slices"
15-
"strconv"
1612
"time"
1713

1814
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
1915
"github.com/cockroachdb/cockroach/pkg/settings"
2016
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
2117
"github.com/cockroachdb/cockroach/pkg/sql/opt/cat"
2218
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
23-
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2419
"github.com/cockroachdb/cockroach/pkg/sql/types"
25-
"github.com/cockroachdb/cockroach/pkg/util/errorutil"
2620
"github.com/cockroachdb/cockroach/pkg/util/log"
27-
"github.com/cockroachdb/cockroach/pkg/util/sentryutil"
2821
"github.com/cockroachdb/errors"
2922
"github.com/cockroachdb/redact"
3023
)
@@ -336,61 +329,6 @@ func forecastColumnStatistics(
336329
}
337330
forecast.HistogramData = &histData
338331
forecast.setHistogramBuckets(hist)
339-
340-
// Verify that the first two buckets (the initial NULL bucket and the first
341-
// non-NULL bucket) both have NumRange=0 and DistinctRange=0. (We must check
342-
// this after calling setHistogramBuckets to account for rounding.) See
343-
// #93892.
344-
for _, bucket := range forecast.Histogram {
345-
if bucket.NumRange != 0 || bucket.DistinctRange != 0 {
346-
// Build a JSON representation of the first several buckets in each
347-
// observed histogram so that we can figure out what happened.
348-
const debugBucketCount = 5
349-
jsonStats := make([]*JSONStatistic, 0, len(observed))
350-
351-
addStat := func(stat *TableStatistic) {
352-
jsonStat := &JSONStatistic{
353-
Name: stat.Name,
354-
CreatedAt: stat.CreatedAt.String(),
355-
Columns: []string{strconv.FormatInt(int64(stat.ColumnIDs[0]), 10)},
356-
RowCount: stat.RowCount,
357-
DistinctCount: stat.DistinctCount,
358-
NullCount: stat.NullCount,
359-
AvgSize: stat.AvgSize,
360-
}
361-
if err := jsonStat.SetHistogram(stat.HistogramData); err == nil &&
362-
len(jsonStat.HistogramBuckets) > debugBucketCount {
363-
// Limit the histogram to the first several buckets.
364-
jsonStat.HistogramBuckets = jsonStat.HistogramBuckets[0:debugBucketCount]
365-
}
366-
// Replace UpperBounds with a hash.
367-
for i := range jsonStat.HistogramBuckets {
368-
hash := md5.Sum([]byte(jsonStat.HistogramBuckets[i].UpperBound))
369-
jsonStat.HistogramBuckets[i].UpperBound = fmt.Sprintf("_%x", hash)
370-
}
371-
jsonStats = append(jsonStats, jsonStat)
372-
}
373-
addStat(forecast)
374-
for i := range observed {
375-
addStat(observed[i])
376-
}
377-
var debugging redact.SafeString
378-
if j, err := json.Marshal(jsonStats); err == nil {
379-
debugging = redact.SafeString(j)
380-
}
381-
err := errorutil.UnexpectedWithIssueErrorf(
382-
93892,
383-
"forecasted histogram had first bucket with non-zero NumRange or DistinctRange: %s",
384-
debugging,
385-
)
386-
sentryutil.SendReport(ctx, &st.SV, err)
387-
return nil, err
388-
}
389-
if bucket.UpperBound != tree.DNull {
390-
// Stop checking after the first non-NULL bucket.
391-
break
392-
}
393-
}
394332
}
395333

396334
return forecast, nil

0 commit comments

Comments
 (0)