Skip to content

Commit

Permalink
feat: modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed Dec 2, 2024
1 parent 4d78763 commit 447745b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tsdb/engine/tsm1/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,10 @@ func (c *DefaultPlanner) Plan(lastWrite time.Time) ([]CompactionGroup, int64) {
var genCount int
for i, group := range generations {
var skip bool
bCount := c.FileStore.BlockCount(group.files[0].Path, 1)

// Skip the file if it's over the max size and contains a full block and it does not have any tombstones
if len(generations) > 2 && group.size() > uint64(maxTSMFileSize) && c.FileStore.BlockCount(group.files[0].Path, 1) == tsdb.DefaultMaxPointsPerBlock && !group.hasTombstones() {
if len(generations) > 2 && group.size() > uint64(maxTSMFileSize) && bCount == tsdb.DefaultMaxPointsPerBlock && !group.hasTombstones() {
skip = true
}

Expand Down
6 changes: 4 additions & 2 deletions tsdb/engine/tsm1/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1585,9 +1585,11 @@ func TestDefaultPlanner_Plan_Multi_Gen_Large_Size(t *testing.T) {
}, tsdb.DefaultCompactFullWriteColdDuration,
)

// TODO(DB): This test currently passes since the mock file store
// sets the block count to 0 for all files
tsm, pLen := cp.Plan(time.Now().Add(-1 * tsdb.DefaultCompactFullWriteColdDuration))
if exp, got := 2, len(tsm); got != exp {
t.Fatalf("tsm file length mismatch: got %v, exp %v", got, exp)
if exp, got := 1, len(tsm); got != exp {
t.Fatalf("tsm group length mismatch: got %v, exp %v", got, exp)
} else if pLen != int64(len(tsm)) {
t.Fatalf("tsm file plan length mismatch: got %v, exp %v", pLen, exp)
}
Expand Down

0 comments on commit 447745b

Please sign in to comment.