Skip to content

Commit

Permalink
Plan at least one task from each group
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
  • Loading branch information
fpetkovski committed Dec 7, 2022
1 parent 25705dc commit e3e94c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,12 @@ func (c *BucketCompactor) planTasks(ctx context.Context, groups []*Group) ([]Gro
}

tasksLimit := c.concurrency
// Make sure we plan at least one task from each group.
if tasksLimit < len(allTasks) {
tasksLimit = len(groups)
}

// If there aren't enough tasks across all groups, plan all available tasks.
if numTasks < tasksLimit {
tasksLimit = numTasks
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/compact/compact_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ func TestGroupCompactE2E(t *testing.T) {
testGroupCompactE2e(t, nil, 2)
}

func TestGroupCompactE2EWithConcurrency(t *testing.T) {
func TestGroupCompactE2EWithoutConcurrency(t *testing.T) {
testGroupCompactE2e(t, nil, 1)
}

func TestGroupCompactE2EWithHighConcurrency(t *testing.T) {
testGroupCompactE2e(t, nil, 20)
}

Expand Down

0 comments on commit e3e94c6

Please sign in to comment.