diff --git a/tsdb/db.go b/tsdb/db.go index e49c5811d..f83c7c495 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 498e26c58..c7ea564d0 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}, }