Skip to content

Commit

Permalink
fix(blooms): Fix strategy logger and add task test (backport k227) (#…
Browse files Browse the repository at this point in the history
…14921)

Co-authored-by: Salva Corts <[email protected]>
  • Loading branch information
loki-gh-app[bot] and salvacorts authored Nov 14, 2024
1 parent 213e8ee commit dc36a1e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/bloombuild/planner/strategies/chunksize.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *ChunkSizeStrategy) Plan(
targetTaskSize := s.limits.BloomTaskTargetSeriesChunksSizeBytes(tenant)

logger := log.With(s.logger, "table", table.Addr(), "tenant", tenant)
level.Debug(s.logger).Log("msg", "loading work for tenant", "target task size", humanize.Bytes(targetTaskSize))
level.Debug(logger).Log("msg", "loading work for tenant", "target task size", humanize.Bytes(targetTaskSize))

// Determine which TSDBs have gaps and need to be processed.
tsdbsWithGaps, err := gapsBetweenTSDBsAndMetas(v1.NewBounds(0, math.MaxUint64), tsdbs, metas)
Expand Down
2 changes: 1 addition & 1 deletion pkg/bloombuild/planner/strategies/splitkeyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *SplitKeyspaceStrategy) Plan(
ownershipRanges := SplitFingerprintKeyspaceByFactor(splitFactor)

logger := log.With(s.logger, "table", table.Addr(), "tenant", tenant)
level.Debug(s.logger).Log("msg", "loading work for tenant", "splitFactor", splitFactor)
level.Debug(logger).Log("msg", "loading work for tenant", "splitFactor", splitFactor)

var tasks []*protos.Task
for _, ownershipRange := range ownershipRanges {
Expand Down
50 changes: 50 additions & 0 deletions pkg/bloombuild/protos/compat_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package protos

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/grafana/loki/v3/pkg/bloombuild/planner/plannertest"
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
"github.com/grafana/loki/v3/pkg/storage/stores/shipper/bloomshipper"
"github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/tsdb"
)

func TestTaskToProtoTask(t *testing.T) {
// Hack to set exportTSInSecs to true
idx := plannertest.TsdbID(1234)
idx, _ = tsdb.ParseSingleTenantTSDBPath(idx.Name())

in := NewTask(plannertest.TestTable, "fake", v1.NewBounds(0, 100), idx, []Gap{
{
Bounds: v1.NewBounds(0, 25),
Series: plannertest.GenSeriesWithStep(v1.NewBounds(0, 10), 2),
Blocks: []bloomshipper.BlockRef{
plannertest.GenBlockRef(0, 2),
plannertest.GenBlockRef(4, 10),
},
},
{
Bounds: v1.NewBounds(30, 50),
Series: plannertest.GenSeriesWithStep(v1.NewBounds(30, 40), 2),
Blocks: []bloomshipper.BlockRef{
plannertest.GenBlockRef(30, 50),
},
},
{
Bounds: v1.NewBounds(60, 100),
Series: plannertest.GenSeriesWithStep(v1.NewBounds(60, 70), 5),
Blocks: []bloomshipper.BlockRef{
plannertest.GenBlockRef(60, 70),
plannertest.GenBlockRef(71, 90),
plannertest.GenBlockRef(91, 100),
},
},
})

out, err := FromProtoTask(in.ToProtoTask())
require.NoError(t, err)

require.Equal(t, in, out)
}

0 comments on commit dc36a1e

Please sign in to comment.