Skip to content

Commit

Permalink
[PLAT-104290] must wrap error as retryable to avoid compactor error exit
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Jin <[email protected]>
  • Loading branch information
jnyi committed Mar 27, 2024
1 parent 26d1383 commit 7d4ac34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pkg/compact/overlapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,19 @@ func (o OverlappingCompactionLifecycleCallback) PreCompactionCallback(ctx contex
outer = currB
prev = curr
}
reason = fmt.Errorf("found full overlapping block: %s > %s", outer.String(), inner.String())
if outer.Thanos.Source == metadata.ReceiveSource {
level.Warn(logger).Log("msg", "bypass if larger blocks are from receive",
"outer", outer.String(), "inner", inner.String())
continue
}
reason = retry(fmt.Errorf("found full overlapping block: %s > %s", outer.String(), inner.String()))
if err := block.MarkForNoCompact(ctx, logger, cg.bkt, inner.ULID, overlappingReason, reason.Error(),
o.noCompaction); err != nil {
return retry(err)
return err
}
if err := block.MarkForNoDownsample(ctx, logger, cg.bkt, inner.ULID, overlappingReason, reason.Error(),
o.noDownsampling); err != nil {
return retry(err)
return err
}
}
return reason
Expand Down
8 changes: 6 additions & 2 deletions pkg/compact/overlapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestPreCompactionCallback(t *testing.T) {
createCustomBlockMeta(7, 2, 7, metadata.CompactorSource, 1),
createCustomBlockMeta(8, 2, 8, metadata.ReceiveSource, 1),
},
expectedMarks: map[int]int{7: 2},
},
{
testName: "full overlapping blocks",
Expand Down Expand Up @@ -116,10 +115,15 @@ func TestPreCompactionCallback(t *testing.T) {
bkt := objstore.NewInMemBucket()
group := &Group{logger: log.NewNopLogger(), bkt: bkt}
err := callback.PreCompactionCallback(ctx, logger, group, tcase.input)
if tcase.expectedErr != nil || len(tcase.expectedMarks) != 0 {
if len(tcase.expectedMarks) != 0 {
testutil.NotOk(t, err)
testutil.Assert(t, IsRetryError(err))
} else if tcase.expectedErr != nil {
testutil.NotOk(t, err)
testutil.Assert(t, IsHaltError(err))
} else {
testutil.Ok(t, err)
testutil.Assert(t, err == nil)
}
objs := bkt.Objects()
expectedSize := 0
Expand Down

0 comments on commit 7d4ac34

Please sign in to comment.