Skip to content

Commit 6cf61c6

Browse files
craig[bot]aa-joshi
andcommitted
Merge #145316
145316: metric: update tick in SQL histogram r=aa-joshi a=aa-joshi Previously, we were not performing tick/rotate histogram during persisting parent histogram metrics. This was resulting higher quantile values for recorded parent metrics values. This patch introduces changes which make sure to tick/rotate if next tick time is before current time. This aligned with existing agg histogram persistence. Fixes: #145056 Epic: CRDB-43153 Release note: None --- (failure) before changes: <img width="1914" alt="failure before changes" src="https://github.com/user-attachments/assets/2d3d2d52-3c05-4a45-ae24-de4c609663ed" /> (success) after changes (first run): <img width="1894" alt="success after changes (run 1)" src="https://github.com/user-attachments/assets/94c0338d-1400-41ed-aa8f-6d128685f5d2" /> (success) after changes (second run): <img width="1885" alt="success after changes (run 2)" src="https://github.com/user-attachments/assets/35a11e9b-ff57-4ace-8555-6c933fb122b5" /> Co-authored-by: Akshay Joshi <[email protected]>
2 parents 35fbea7 + b2fcbf3 commit 6cf61c6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/util/metric/aggmetric/agg_metric.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ func (sm *SQLMetric) getChildByLabelConfig(
268268
) (ChildMetric, bool) {
269269
var childMetric ChildMetric
270270
switch sm.labelConfig.Load() {
271+
case uint64(metric.LabelConfigDisabled):
272+
return nil, false
271273
case uint64(metric.LabelConfigDB):
272274
childMetric = sm.getOrAddChild(f, db)
273275
return childMetric, true

pkg/util/metric/aggmetric/histogram.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ func (sh *SQLHistogram) GetMetadata() metric.Metadata {
294294

295295
// Inspect is part of the metric.Iterable interface.
296296
func (sh *SQLHistogram) Inspect(f func(interface{})) {
297+
func() {
298+
sh.ticker.Lock()
299+
defer sh.ticker.Unlock()
300+
tick.MaybeTick(&sh.ticker)
301+
}()
297302
f(sh)
298303
}
299304

0 commit comments

Comments
 (0)