Update tsdb/record/record.go

Co-authored-by: Björn Rabenstein <beorn@grafana.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
This commit is contained in:
George Krajcsovits 2025-09-24 13:50:03 +02:00 committed by György Krajcsovits
parent 30f941c57c
commit 35d9f28c87
No known key found for this signature in database
GPG Key ID: 47A8F9CE80FD7C7F
2 changed files with 4 additions and 4 deletions

View File

@ -461,7 +461,7 @@ func (d *Decoder) HistogramSamples(rec []byte, histograms []RefHistogramSample)
DecodeHistogram(&dec, rh.H) DecodeHistogram(&dec, rh.H)
if !histogram.IsKnownSchema(rh.H.Schema) { if !histogram.IsKnownSchema(rh.H.Schema) {
d.logger.Warn("invalid histogram schema in WAL record", "schema", rh.H.Schema, "timestamp", rh.T) d.logger.Warn("skipping histogram with unknown schema in WAL record", "schema", rh.H.Schema, "timestamp", rh.T)
continue continue
} }
if rh.H.Schema > histogram.ExponentialSchemaMax && rh.H.Schema <= histogram.ExponentialSchemaMaxReserved { if rh.H.Schema > histogram.ExponentialSchemaMax && rh.H.Schema <= histogram.ExponentialSchemaMaxReserved {
@ -565,7 +565,7 @@ func (d *Decoder) FloatHistogramSamples(rec []byte, histograms []RefFloatHistogr
DecodeFloatHistogram(&dec, rh.FH) DecodeFloatHistogram(&dec, rh.FH)
if !histogram.IsKnownSchema(rh.FH.Schema) { if !histogram.IsKnownSchema(rh.FH.Schema) {
d.logger.Warn("invalid histogram schema in WAL record", "schema", rh.FH.Schema, "timestamp", rh.T) d.logger.Warn("skipping histogram with unknown schema in WAL record", "schema", rh.FH.Schema, "timestamp", rh.T)
continue continue
} }
if rh.FH.Schema > histogram.ExponentialSchemaMax && rh.FH.Schema <= histogram.ExponentialSchemaMaxReserved { if rh.FH.Schema > histogram.ExponentialSchemaMax && rh.FH.Schema <= histogram.ExponentialSchemaMaxReserved {

View File

@ -256,7 +256,7 @@ func TestRecord_DecodeInvalidHistogramSchema(t *testing.T) {
decHistograms, err := dec.HistogramSamples(histSamples, nil) decHistograms, err := dec.HistogramSamples(histSamples, nil)
require.NoError(t, err) require.NoError(t, err)
require.Empty(t, decHistograms) require.Empty(t, decHistograms)
require.Contains(t, output.String(), "invalid histogram schema in WAL record") require.Contains(t, output.String(), "skipping histogram with unknown schema in WAL record")
}) })
} }
} }
@ -291,7 +291,7 @@ func TestRecord_DecodeInvalidFloatHistogramSchema(t *testing.T) {
decHistograms, err := dec.FloatHistogramSamples(histSamples, nil) decHistograms, err := dec.FloatHistogramSamples(histSamples, nil)
require.NoError(t, err) require.NoError(t, err)
require.Empty(t, decHistograms) require.Empty(t, decHistograms)
require.Contains(t, output.String(), "invalid histogram schema in WAL record") require.Contains(t, output.String(), "skipping histogram with unknown schema in WAL record")
}) })
} }
} }