Browse Source

tsdb.BeyondTimeRetention: Fix comment and test at retention duration

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
pull/13790/head
Arve Knudsen 8 months ago
parent
commit
9c7a734063
  1. 2
      tsdb/db.go
  2. 4
      tsdb/db_test.go

2
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:] {

4
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},
}

Loading…
Cancel
Save