From 9c7a7340630b61d296bb770e6d450b09be759878 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 19 Mar 2024 09:10:21 +0100 Subject: [PATCH] tsdb.BeyondTimeRetention: Fix comment and test at retention duration Signed-off-by: Arve Knudsen --- tsdb/db.go | 2 +- tsdb/db_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tsdb/db.go b/tsdb/db.go index e49c5811d2..f83c7c4958 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -1608,7 +1608,7 @@ func BeyondTimeRetention(db *DB, blocks []*Block) (deletable map[ulid.ULID]struc deletable = make(map[ulid.ULID]struct{}) for i, block := range blocks { - // The difference between the first block and this block is larger than + // The difference between the first block and this block is greater than or equal to // the retention period so any blocks after that are added as deletable. if i > 0 && blocks[0].Meta().MaxTime-block.Meta().MaxTime >= db.opts.RetentionDuration { for _, b := range blocks[i:] { diff --git a/tsdb/db_test.go b/tsdb/db_test.go index 498e26c588..c7ea564d0e 100644 --- a/tsdb/db_test.go +++ b/tsdb/db_test.go @@ -689,10 +689,10 @@ func TestDB_BeyondTimeRetention(t *testing.T) { require.NoError(t, db.Close()) }() - // We have 4 blocks, 3 of which are beyond the retention duration. + // We have 4 blocks, 3 of which are beyond or at the retention duration. metas := []BlockMeta{ {MinTime: 300, MaxTime: 500}, - {MinTime: 200, MaxTime: 300}, + {MinTime: 200, MaxTime: 400}, {MinTime: 100, MaxTime: 200}, {MinTime: 0, MaxTime: 100}, }