From d0d361da53eb825fc2207fa483b2672c0a6da2f8 Mon Sep 17 00:00:00 2001 From: Oleg Zaytsev Date: Fri, 7 Jun 2024 16:09:53 +0200 Subject: [PATCH] headIndexReader.LabelNamesFor: skip not found series It's quite common during the compaction cycle to hold series IDs for series that aren't in the TSDB head anymore. We shouldn't fail if that happens, as the caller has no way to figure out which one of the IDs doesn't exist. Fixes https://github.com/prometheus/prometheus/issues/14278 Signed-off-by: Oleg Zaytsev --- tsdb/head_read.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsdb/head_read.go b/tsdb/head_read.go index df15abcd5..c53e10956 100644 --- a/tsdb/head_read.go +++ b/tsdb/head_read.go @@ -277,7 +277,9 @@ func (h *headIndexReader) LabelNamesFor(ctx context.Context, ids ...storage.Seri } memSeries := h.head.series.getByID(chunks.HeadSeriesRef(id)) if memSeries == nil { - return nil, storage.ErrNotFound + // Series not found, this happens during compaction, + // when series was garbage collected after the caller got the series IDs. + continue } memSeries.lset.Range(func(lbl labels.Label) { namesMap[lbl.Name] = struct{}{}