Skip to content

Commit

Permalink
[PLAT-102919] stop halting even no vertical compaction
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Jin <[email protected]>
  • Loading branch information
jnyi committed Mar 14, 2024
1 parent d0a908a commit 5d6334e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,41 @@ jobs:
- name: Linting & vetting
run: make go-lint

unit:
strategy:
fail-fast: false
runs-on: ubuntu-latest
name: Thanos unit tests
env:
GOBIN: /tmp/.bin
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go.
uses: actions/setup-go@v3
with:
go-version: 1.21.x

- name: Install Prometheus
run: |
wget https://github.com/prometheus/prometheus/releases/download/v2.50.0/prometheus-2.50.0.linux-amd64.tar.gz
tar xvf prometheus-2.50.0.linux-amd64.tar.gz
mv prometheus-2.50.0.linux-amd64/prometheus prometheus-2.50.0.linux-amd64/prometheus-v0.37.0
echo prometheus-2.50.0.linux-amd64 >> $GITHUB_PATH
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/.cache/golangci-lint
~/go/pkg/mod
~/prometheus-2.50.0.linux-amd64
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Run unit tests
run: make test-local

e2e:
strategy:
fail-fast: false
Expand Down
13 changes: 11 additions & 2 deletions pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package compact

import (
"bytes"
"context"
"fmt"
"math"
Expand Down Expand Up @@ -1069,7 +1070,7 @@ func (cg *Group) removeOverlappingBlocks(ctx context.Context, toCompact []*metad
for _, m := range toCompact {
if m.ULID.Compare(kept.ULID) == 0 {
level.Info(cg.logger).Log("msg", "skip the longest overlapping block", "block", m.String(),
"level", m.Compaction.Level, "source", m.Thanos.Source, "labels", m.Thanos.Labels)
"level", m.Compaction.Level, "source", m.Thanos.Source, "labels", map2str(m.Thanos.Labels))
continue
}
cg.overlappingBlocks.Inc()
Expand All @@ -1078,9 +1079,17 @@ func (cg *Group) removeOverlappingBlocks(ctx context.Context, toCompact []*metad
return nil
}

func map2str(labels map[string]string) string {
b := new(bytes.Buffer)
for k, v := range labels {
fmt.Fprintf(b, "%s=%s,", k, v)
}
return b.String()
}

func DeleteBlockNow(ctx context.Context, logger log.Logger, bkt objstore.Bucket, m *metadata.Meta, dir string) error {
level.Warn(logger).Log("msg", "delete polluted block immediately", "block", m.String(),
"level", m.Compaction.Level, "source", m.Thanos.Source, "labels", m.Thanos.Labels)
"level", m.Compaction.Level, "source", m.Thanos.Source, "labels", map2str(m.Thanos.Labels))
if err := block.Delete(ctx, logger, bkt, m.ULID); err != nil {
return errors.Wrapf(err, "delete overlapping block %s", m.String())
}
Expand Down

0 comments on commit 5d6334e

Please sign in to comment.