Skip to content

Commit 1a7f65a

Browse files
committed
address comments
Signed-off-by: Roy Chiang <[email protected]>
1 parent 3ea1e36 commit 1a7f65a

File tree

4 files changed

+7
-20
lines changed

4 files changed

+7
-20
lines changed

docs/guides/shuffle-sharding.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ Note that when using sharding strategy, each rule group is evaluated by single r
160160
Cortex compactor can run in three modes:
161161

162162
1. **No sharding at all.** This is the most basic mode of the compactor. It is activated by using `-compactor.sharding-enabled=false` (default). In this mode every compactor will run every compaction.
163-
2. **Default sharding**, activated by using `-compactor.sharding-enabled=true` and `-compactor.sharding-strategy=default` (default). In this mode compactors register themselves into the ring. Each compactor will then select and evaluate only those users that it "owns".
164-
3. **Shuffle sharding**, activated by using `-compactor.sharding-enabled=true` and `-compactor.sharding-strategy=shuffle-sharding`. Similarly to default sharding, compactors use the ring to distribute workload, but compactions groups for each tenant can only be evaluated on limited number of compactors (`-compactor.tenant-shard-size`, can also be set per tenant as `compactor_tenant_shard_size` in overrides).
165-
166-
The Cortex compactor by default shards by tenant ID when sharding is enabled.
163+
2. **Default sharding**, activated by using `-compactor.sharding-enabled=true` and `-compactor.sharding-strategy=default` (default). In this mode compactors register themselves into the ring. One single tenant will belong to only 1 compactor.
164+
3. **Shuffle sharding**, activated by using `-compactor.sharding-enabled=true` and `-compactor.sharding-strategy=shuffle-sharding`. Similarly to default sharding, but compactions for each tenant can be carried out on multiple compactors (`-compactor.tenant-shard-size`, can also be set per tenant as `compactor_tenant_shard_size` in overrides).
167165

168166
With shuffle sharding selected as the sharding strategy, a subset of the compactors will be used to handle a user based on the shard size.
169167

pkg/compactor/compactor.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ var (
5151

5252
supportedShardingStrategies = []string{util.ShardingStrategyDefault, util.ShardingStrategyShuffle}
5353
errInvalidShardingStrategy = errors.New("invalid sharding strategy")
54-
errShardingRequired = errors.New("sharding must be enabled to use shuffle-sharding sharding strategy")
5554
errInvalidTenantShardSize = errors.New("invalid tenant shard size, the value must be greater than 0")
5655

5756
DefaultBlocksGrouperFactory = func(ctx context.Context, cfg Config, bkt objstore.Bucket, logger log.Logger, reg prometheus.Registerer, blocksMarkedForDeletion , blocksMarkedForNoCompaction, garbageCollectedBlocks prometheus.Counter, _ prometheus.Gauge, _ *ring.Ring, _ *ring.Lifecycler, _ Limits, _ string) compact.Grouper {
@@ -231,10 +230,8 @@ func (cfg *Config) Validate(limits validation.Limits) error {
231230
return errInvalidShardingStrategy
232231
}
233232

234-
if cfg.ShardingStrategy == util.ShardingStrategyShuffle {
235-
if !cfg.ShardingEnabled {
236-
return errShardingRequired
237-
} else if limits.CompactorTenantShardSize <= 0 {
233+
if cfg.ShardingEnabled && cfg.ShardingStrategy == util.ShardingStrategyShuffle {
234+
if limits.CompactorTenantShardSize <= 0 {
238235
return errInvalidTenantShardSize
239236
}
240237
}
@@ -350,10 +347,10 @@ func newCompactor(
350347
limits Limits,
351348
) (*Compactor, error) {
352349
var remainingPlannedCompactions prometheus.Gauge
353-
if compactorCfg.ShardingStrategy == "shuffle-sharding" {
350+
if compactorCfg.ShardingStrategy == util.ShardingStrategyShuffle {
354351
remainingPlannedCompactions = promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
355352
Name: "cortex_compactor_remaining_planned_compactions",
356-
Help: "Total number of plans that remain to be compacted.",
353+
Help: "Total number of plans that remain to be compacted. Only available with shuffle-sharding strategy",
357354
})
358355
}
359356
c := &Compactor{

pkg/compactor/compactor_test.go

-8
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ func TestConfig_Validate(t *testing.T) {
125125
},
126126
expected: "",
127127
},
128-
"should fail with shuffle sharding strategy selected without sharding enabled": {
129-
setup: func(cfg *Config) {
130-
cfg.ShardingStrategy = util.ShardingStrategyShuffle
131-
cfg.ShardingEnabled = false
132-
},
133-
initLimits: func(_ *validation.Limits) {},
134-
expected: errShardingRequired.Error(),
135-
},
136128
"should fail with bad compactor tenant shard size": {
137129
setup: func(cfg *Config) {
138130
cfg.ShardingStrategy = util.ShardingStrategyShuffle

pkg/compactor/shuffle_sharding_grouper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (g *ShuffleShardingGrouper) Groups(blocks map[ulid.ULID]*metadata.Meta) (re
130130
return nil, errors.Wrap(err, "unable to check sub-ring for compactor ownership")
131131
}
132132
if !onSubring {
133-
level.Info(g.logger).Log("msg", "compactor is not on the current sub-ring skipping user", "user", g.userID)
133+
level.Debug(g.logger).Log("msg", "compactor is not on the current sub-ring skipping user", "user", g.userID)
134134
return outGroups, nil
135135
}
136136
// Metrics for the remaining planned compactions

0 commit comments

Comments
 (0)