Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip compaction if there is only 1 block available for shuffle-sharding compactor #4756

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* [BUGFIX] Ruler: Fixed leaking notifiers after users are removed #4718
* [BUGFIX] Distributor: Fix a memory leak in distributor due to the cluster label. #4739
* [BUGFIX] Memberlist: Avoid clock skew by limiting the timestamp accepted on gossip. #4750

* [BUGFIX] Compactor: skip compaction if there is only 1 block available for shuffle-sharding compactor. #4756

## 1.11.0 2021-11-25

Expand Down
4 changes: 4 additions & 0 deletions pkg/compactor/shuffle_sharding_planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ func (p *ShuffleShardingPlanner) Plan(_ context.Context, metasByMinTime []*metad
resultMetas = append(resultMetas, b)
}

if len(resultMetas) < 2 {
return nil, nil
}

return resultMetas, nil
}
36 changes: 36 additions & 0 deletions pkg/compactor/shuffle_sharding_planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
func TestShuffleShardingPlanner_Plan(t *testing.T) {
block1ulid := ulid.MustNew(1, nil)
block2ulid := ulid.MustNew(2, nil)
block3ulid := ulid.MustNew(3, nil)

tests := map[string]struct {
ranges []int64
Expand Down Expand Up @@ -137,6 +138,13 @@ func TestShuffleShardingPlanner_Plan(t *testing.T) {
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
{
BlockMeta: tsdb.BlockMeta{
ULID: block3ulid,
MinTime: 1 * time.Hour.Milliseconds(),
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
},
expected: []*metadata.Meta{
{
Expand All @@ -146,7 +154,35 @@ func TestShuffleShardingPlanner_Plan(t *testing.T) {
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
{
BlockMeta: tsdb.BlockMeta{
ULID: block3ulid,
MinTime: 1 * time.Hour.Milliseconds(),
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
},
},
"test should not compact if there is only 1 compactable block": {
ranges: []int64{2 * time.Hour.Milliseconds()},
noCompactBlocks: map[ulid.ULID]*metadata.NoCompactMark{block1ulid: {}},
blocks: []*metadata.Meta{
{
BlockMeta: tsdb.BlockMeta{
ULID: block1ulid,
MinTime: 1 * time.Hour.Milliseconds(),
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
{
BlockMeta: tsdb.BlockMeta{
ULID: block2ulid,
MinTime: 1 * time.Hour.Milliseconds(),
MaxTime: 2 * time.Hour.Milliseconds(),
},
},
},
expected: []*metadata.Meta{},
},
}

Expand Down