From 452da0025d028852a0e1a024c8939320637ceea7 Mon Sep 17 00:00:00 2001 From: Salva Corts Date: Mon, 16 Dec 2024 12:16:23 +0100 Subject: [PATCH] Fix test --- .../stores/shipper/indexshipper/tsdb/index/index.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/storage/stores/shipper/indexshipper/tsdb/index/index.go b/pkg/storage/stores/shipper/indexshipper/tsdb/index/index.go index 83be2601bd125..e14d2d18e8fb2 100644 --- a/pkg/storage/stores/shipper/indexshipper/tsdb/index/index.go +++ b/pkg/storage/stores/shipper/indexshipper/tsdb/index/index.go @@ -2248,6 +2248,11 @@ func (dec *Decoder) readSeriesStats(version int, d *encoding.Decbuf, stats **Str return nil } + // If stats are not requested (stats are nil), we can just skip through the stats + if stats == nil { + return dec.skipSeriesStats(d) + } + nSMFieldNames := d.Uvarint() fields := make(map[string]struct{}, nSMFieldNames) @@ -2266,6 +2271,14 @@ func (dec *Decoder) readSeriesStats(version int, d *encoding.Decbuf, stats **Str return nil } +func (dec *Decoder) skipSeriesStats(d *encoding.Decbuf) error { + nSMFieldNames := d.Uvarint() + for i := 0; i < nSMFieldNames; i++ { + _ = d.Uvarint() + } + return d.Err() +} + // prepSeriesBy returns series labels and chunks for a series and only returning selected `by` label names. // If `by` is empty, it returns all labels for the series. func (dec *Decoder) prepSeriesBy(version int, b []byte, lbls *labels.Labels, chks *[]ChunkMeta, stats **StreamStats, by map[string]struct{}) (*encoding.Decbuf, uint64, error) {