Skip to content

Commit

Permalink
don't halt compaction due to overlapping sources when vertical compac…
Browse files Browse the repository at this point in the history
…tion is enabled (thanos-io#7225)

Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored and jnyi committed Jun 1, 2024
1 parent 5ac1de3 commit 1dd3138
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,14 +807,17 @@ type CompactionLifecycleCallback interface {
type DefaultCompactionLifecycleCallback struct {
}

func (c DefaultCompactionLifecycleCallback) PreCompactionCallback(_ context.Context, _ log.Logger, _ *Group, toCompactBlocks []*metadata.Meta) error {
func (c DefaultCompactionLifecycleCallback) PreCompactionCallback(_ context.Context, logger log.Logger, cg *Group, toCompactBlocks []*metadata.Meta) error {
// Due to #183 we verify that none of the blocks in the plan have overlapping sources.
// This is one potential source of how we could end up with duplicated chunks.
uniqueSources := map[ulid.ULID]struct{}{}
for _, m := range toCompactBlocks {
for _, s := range m.Compaction.Sources {
if _, ok := uniqueSources[s]; ok {
return halt(errors.Errorf("overlapping sources detected for plan %v", toCompactBlocks))
if !cg.enableVerticalCompaction {
return halt(errors.Errorf("overlapping sources detected for plan %v", toCompactBlocks))
}
level.Warn(logger).Log("msg", "overlapping sources detected for plan", "duplicated_block", s, "to_compact_blocks", fmt.Sprintf("%v", toCompactBlocks))
}
uniqueSources[s] = struct{}{}
}
Expand Down

0 comments on commit 1dd3138

Please sign in to comment.