Merge pull request #17298 from prometheus/release-3.7
buf.build / lint and publish (push) Waiting to run Details
CI / Go tests (push) Waiting to run Details
CI / More Go tests (push) Waiting to run Details
CI / Go tests with previous Go version (push) Waiting to run Details
CI / UI tests (push) Waiting to run Details
CI / Go tests on Windows (push) Waiting to run Details
CI / Mixins tests (push) Waiting to run Details
CI / Build Prometheus for common architectures (0) (push) Waiting to run Details
CI / Build Prometheus for common architectures (1) (push) Waiting to run Details
CI / Build Prometheus for common architectures (2) (push) Waiting to run Details
CI / Build Prometheus for all architectures (0) (push) Waiting to run Details
CI / Build Prometheus for all architectures (1) (push) Waiting to run Details
CI / Build Prometheus for all architectures (10) (push) Waiting to run Details
CI / Build Prometheus for all architectures (11) (push) Waiting to run Details
CI / Build Prometheus for all architectures (2) (push) Waiting to run Details
CI / Build Prometheus for all architectures (3) (push) Waiting to run Details
CI / Build Prometheus for all architectures (4) (push) Waiting to run Details
CI / Build Prometheus for all architectures (5) (push) Waiting to run Details
CI / Build Prometheus for all architectures (6) (push) Waiting to run Details
CI / Build Prometheus for all architectures (7) (push) Waiting to run Details
CI / Build Prometheus for all architectures (8) (push) Waiting to run Details
CI / Build Prometheus for all architectures (9) (push) Waiting to run Details
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions Details
CI / Check generated parser (push) Waiting to run Details
CI / golangci-lint (push) Waiting to run Details
CI / fuzzing (push) Waiting to run Details
CI / codeql (push) Waiting to run Details
CI / Publish main branch artifacts (push) Blocked by required conditions Details
CI / Publish release artefacts (push) Blocked by required conditions Details
CI / Publish UI on npm Registry (push) Blocked by required conditions Details
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run Details

Merging back release-3.7 branch into master
This commit is contained in:
Björn Rabenstein 2025-10-07 16:23:36 +02:00 committed by GitHub
commit 68e4d4e5eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 9 deletions

View File

@ -570,7 +570,10 @@ func (a *headAppender) getCurrentBatch(st sampleType, s chunks.HeadSeriesRef) *a
b.exemplars = h.getExemplarBuffer() b.exemplars = h.getExemplarBuffer()
} }
clear(a.typesInBatch) clear(a.typesInBatch)
if st != stNone { switch st {
case stHistogram, stFloatHistogram, stCustomBucketHistogram, stCustomBucketFloatHistogram:
// We only record histogram sample types in the map.
// Floats are implicit.
a.typesInBatch[s] = st a.typesInBatch[s] = st
} }
a.batches = append(a.batches, &b) a.batches = append(a.batches, &b)
@ -597,14 +600,32 @@ func (a *headAppender) getCurrentBatch(st sampleType, s chunks.HeadSeriesRef) *a
} }
prevST, ok := a.typesInBatch[s] prevST, ok := a.typesInBatch[s]
switch { switch {
case !ok: // New series. Add it to map and return current batch. case prevST == st:
// An old series of some histogram type with the same type being appended.
// Continue the batch.
return lastBatch
case !ok && st == stFloat:
// A new float series, or an old float series that gets floats appended.
// Note that we do not track stFloat in typesInBatch.
// Continue the batch.
return lastBatch
case st == stFloat:
// A float being appended to a histogram series.
// Start a new batch.
return newBatch()
case !ok:
// A new series of some histogram type, or some histogram type
// being appended to on old float series. Even in the latter
// case, we don't need to start a new batch because histograms
// after floats are fine.
// Add new sample type to the map and continue batch.
a.typesInBatch[s] = st a.typesInBatch[s] = st
return lastBatch return lastBatch
case prevST == st: // Old series, same type. Just return batch. default:
return lastBatch // One histogram type changed to another.
// Start a new batch.
return newBatch()
} }
// An old series got a new type. Start new batch.
return newBatch()
} }
// appendable checks whether the given sample is valid for appending to the series. // appendable checks whether the given sample is valid for appending to the series.
@ -1068,6 +1089,8 @@ func (a *headAppender) log() error {
return fmt.Errorf("log metadata: %w", err) return fmt.Errorf("log metadata: %w", err)
} }
} }
// It's important to do (float) Samples before histogram samples
// to end up with the correct order.
if len(b.floats) > 0 { if len(b.floats) > 0 {
rec = enc.Samples(b.floats, buf) rec = enc.Samples(b.floats, buf)
buf = rec[:0] buf = rec[:0]
@ -1748,8 +1771,9 @@ func (a *headAppender) Commit() (err error) {
}() }()
for _, b := range a.batches { for _, b := range a.batches {
// Do not change the order of these calls. The staleness marker // Do not change the order of these calls. We depend on it for
// handling depends on it. // correct commit order of samples and for the staleness marker
// handling.
a.commitFloats(b, acc) a.commitFloats(b, acc)
a.commitHistograms(b, acc) a.commitHistograms(b, acc)
a.commitFloatHistograms(b, acc) a.commitFloatHistograms(b, acc)
@ -2238,7 +2262,6 @@ func (a *headAppender) Rollback() (err error) {
}() }()
var series *memSeries var series *memSeries
fmt.Println("ROLLBACK")
for _, b := range a.batches { for _, b := range a.batches {
for i := range b.floats { for i := range b.floats {
series = b.floatSeries[i] series = b.floatSeries[i]