Skip to content

Commit

Permalink
fix: Make sure we don't overwrite matchers while sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Aug 2, 2024
1 parent cfd0fbd commit 3bd8918
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ func (t *Loki) initMetastore() (services.Service, error) {
return nil, nil
}
if t.Cfg.isTarget(All) {
t.Cfg.MetastoreClient.MetastoreAddress = fmt.Sprintf("localhost:%s", t.Cfg.Server.GRPCListenAddress)
t.Cfg.MetastoreClient.MetastoreAddress = fmt.Sprintf("localhost:%d", t.Cfg.Server.GRPCListenPort)
}
m, err := metastore.New(t.Cfg.Metastore, log.With(util_log.Logger, "component", "metastore"), prometheus.DefaultRegisterer, t.health)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions pkg/querier-rf1/wal/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,16 @@ func (q *Querier) matchingChunks(ctx context.Context, tenantID string, from, thr
return lazyChunks, nil
}

func (q *Querier) forSeries(ctx context.Context, req *metastorepb.ListBlocksForQueryRequest, fn func(string, *labels.ScratchBuilder, *chunks.Meta) error, ms ...*labels.Matcher) error {
func (q *Querier) forSeries(ctx context.Context, req *metastorepb.ListBlocksForQueryRequest, fn func(string, *labels.ScratchBuilder, *chunks.Meta) error, matchers ...*labels.Matcher) error {
// copy matchers to avoid modifying the original slice.
ms := make([]*labels.Matcher, 0, len(matchers)+1)
ms = append(ms, matchers...)
ms = append(ms, labels.MustNewMatcher(labels.MatchEqual, index.TenantLabel, req.TenantId))

return q.forIndices(ctx, req, func(ir *index.Reader, id string) error {
bufLbls := labels.ScratchBuilder{}
chunks := make([]chunks.Meta, 0, 1)
p, err := ir.PostingsForMatchers(ctx, req.TenantId, ms...)
p, err := ir.PostingsForMatchers(ctx, ms...)
if err != nil {
return err
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/storage/wal/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1929,9 +1929,7 @@ func yoloString(b []byte) string {

// PostingsForMatchers assembles a single postings iterator against the index reader
// based on the given matchers. The resulting postings are not ordered by series.
func (r *Reader) PostingsForMatchers(ctx context.Context, tenantID string, ms ...*labels.Matcher) (index.Postings, error) {
ms = append(ms, labels.MustNewMatcher(labels.MatchEqual, TenantLabel, tenantID))

func (r *Reader) PostingsForMatchers(ctx context.Context, ms ...*labels.Matcher) (index.Postings, error) {
var its, notIts []index.Postings
// See which label must be non-empty.
// Optimization for case like {l=~".", l!="1"}.
Expand Down

0 comments on commit 3bd8918

Please sign in to comment.