head.checkWALExpiry -> head.getWALExpiry; check implies a comparison that doesn't happen in the function

Signed-off-by: Patryk Prus <p@trykpr.us>
This commit is contained in:
Patryk Prus 2025-02-28 12:06:39 -05:00
parent 786d3d99ba
commit f2f1357917
No known key found for this signature in database
GPG key ID: 795650115CA6A58F
2 changed files with 4 additions and 4 deletions

View file

@ -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
}

View file

@ -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) {