From f2f13579175f53df4dabf6e241b444c95cd2b9ac Mon Sep 17 00:00:00 2001 From: Patryk Prus
Date: Fri, 28 Feb 2025 12:06:39 -0500 Subject: [PATCH] head.checkWALExpiry -> head.getWALExpiry; check implies a comparison that doesn't happen in the function Signed-off-by: Patryk Prus
--- tsdb/head.go | 4 ++-- tsdb/head_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tsdb/head.go b/tsdb/head.go index 95d15f7641..43b8e10ab1 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -1262,7 +1262,7 @@ func (h *Head) IsQuerierCollidingWithTruncation(querierMint, querierMaxt int64) return false, false, 0 } -func (h *Head) checkWALExpiry(id chunks.HeadSeriesRef) (int, bool) { +func (h *Head) getWALExpiry(id chunks.HeadSeriesRef) (int, bool) { h.walExpiriesMtx.Lock() defer h.walExpiriesMtx.Unlock() @@ -1286,7 +1286,7 @@ func (h *Head) keepSeriesInWALCheckpoint(id chunks.HeadSeriesRef, last int) bool } // Keep the record if the series has an expiry set. - keepUntil, ok := h.checkWALExpiry(id) + keepUntil, ok := h.getWALExpiry(id) return ok && keepUntil > last } diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 5435985234..48fe7c3cce 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -729,13 +729,13 @@ func TestHead_ReadWAL(t *testing.T) { // Duplicate series record should not be written to the head. require.Nil(t, s101) // But it should have a WAL expiry set. - keepUntil, ok := head.checkWALExpiry(101) + keepUntil, ok := head.getWALExpiry(101) require.True(t, ok) _, last, err := wlog.Segments(w.Dir()) require.NoError(t, err) require.Equal(t, last, keepUntil) // Only the duplicate series record should have a WAL expiry set. - _, ok = head.checkWALExpiry(50) + _, ok = head.getWALExpiry(50) require.False(t, ok) expandChunk := func(c chunkenc.Iterator) (x []sample) {