Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Upgrade google.golang.org/grpc to v1.69.0 #10224

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
golang.org/x/net v0.35.0
golang.org/x/sync v0.11.0
golang.org/x/time v0.9.0
google.golang.org/grpc v1.70.0
google.golang.org/grpc v1.71.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -111,7 +111,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 // indirect
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect
github.com/ebitengine/purego v0.8.1 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand Down Expand Up @@ -332,7 +331,3 @@ replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-aler
// - https://github.com/grafana/franz-go/pull/3
// - https://github.com/grafana/franz-go/pull/4
replace github.com/twmb/franz-go => github.com/grafana/franz-go v0.0.0-20241009100846-782ba1442937

// Pin Google GRPC to v1.65.0 as v1.66.0 has API changes and also potentially performance regressions.
// Following https://github.com/grafana/dskit/pull/581
replace google.golang.org/grpc => google.golang.org/grpc v1.65.0
1,194 changes: 66 additions & 1,128 deletions go.sum

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,14 @@ func NextOrCleanup(next PushFunc, pushReq *Request) (_ PushFunc, maybeCleanup fu
return next(ctx, req)
},
func() {
if cleanupInDefer {
pushReq.CleanUp()
if !cleanupInDefer {
return
}

req, _ := pushReq.WriteRequest()
pushReq.CleanUp()
if req != nil {
req.FreeBuffer()
}
}
}
Expand All @@ -1608,6 +1614,7 @@ func NextOrCleanup(next PushFunc, pushReq *Request) (_ PushFunc, maybeCleanup fu
func (d *Distributor) Push(ctx context.Context, req *mimirpb.WriteRequest) (*mimirpb.WriteResponse, error) {
pushReq := NewParsedRequest(req)
pushReq.AddCleanup(func() {
req.FreeBuffer()
mimirpb.ReuseSlice(req.Timeseries)
})

Expand Down Expand Up @@ -2795,6 +2802,11 @@ func (d *Distributor) MetricsForLabelMatchers(ctx context.Context, from, through
if err != nil {
return nil, err
}
defer func() {
for _, resp := range resps {
resp.Release()
}
}()

metrics := map[uint64]labels.Labels{}
respsLoop:
Expand All @@ -2815,6 +2827,8 @@ respsLoop:
if err := queryLimiter.AddSeries(m); err != nil {
return nil, err
}
// Make safe copies of labels.
m.InternStrings(strings.Clone)
result = append(result, m)
}
return result, nil
Expand Down
42 changes: 27 additions & 15 deletions pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6588,28 +6588,34 @@ func (i *mockIngester) QueryStream(ctx context.Context, req *client.QueryRequest

if i.disableStreamingResponse || req.StreamingChunksBatchSize == 0 {
nonStreamingResponses = append(nonStreamingResponses, &client.QueryStreamResponse{
Chunkseries: []client.TimeSeriesChunk{
Chunkseries: []client.CustomTimeSeriesChunk{
{
Labels: ts.Labels,
Chunks: wireChunks,
TimeSeriesChunk: &client.TimeSeriesChunk{
Labels: ts.Labels,
Chunks: wireChunks,
},
},
},
})
} else {
streamingLabelResponses = append(streamingLabelResponses, &client.QueryStreamResponse{
StreamingSeries: []client.QueryStreamSeries{
StreamingSeries: []client.CustomQueryStreamSeries{
{
Labels: ts.Labels,
ChunkCount: int64(len(wireChunks)),
QueryStreamSeries: &client.QueryStreamSeries{
Labels: ts.Labels,
ChunkCount: int64(len(wireChunks)),
},
},
},
})

streamingChunkResponses = append(streamingChunkResponses, &client.QueryStreamResponse{
StreamingSeriesChunks: []client.QueryStreamSeriesChunks{
StreamingSeriesChunks: []client.CustomQueryStreamSeriesChunks{
{
SeriesIndex: uint64(seriesIndex),
Chunks: wireChunks,
QueryStreamSeriesChunks: &client.QueryStreamSeriesChunks{
SeriesIndex: uint64(seriesIndex),
Chunks: wireChunks,
},
},
},
})
Expand Down Expand Up @@ -6689,15 +6695,17 @@ func (i *mockIngester) QueryExemplars(ctx context.Context, req *client.ExemplarQ
}

if len(exemplars) > 0 {
res.Timeseries = append(res.Timeseries, mimirpb.TimeSeries{
Labels: series.Labels,
Exemplars: exemplars,
res.Timeseries = append(res.Timeseries, mimirpb.CustomTimeSeries{
TimeSeries: &mimirpb.TimeSeries{
Labels: series.Labels,
Exemplars: exemplars,
},
})
}
}

// Sort series by labels because the real ingester returns sorted ones.
slices.SortFunc(res.Timeseries, func(a, b mimirpb.TimeSeries) int {
slices.SortFunc(res.Timeseries, func(a, b mimirpb.CustomTimeSeries) int {
aKey := mimirpb.FromLabelAdaptersToKeyString(a.Labels)
bKey := mimirpb.FromLabelAdaptersToKeyString(b.Labels)
return strings.Compare(aKey, bKey)
Expand Down Expand Up @@ -6729,13 +6737,17 @@ func (i *mockIngester) MetricsForLabelMatchers(ctx context.Context, req *client.
for _, matchers := range multiMatchers {
for _, ts := range i.timeseries {
if match(ts.Labels, matchers) {
response.Metric = append(response.Metric, &mimirpb.Metric{Labels: ts.Labels})
response.Metric = append(response.Metric, mimirpb.CustomMetric{
Metric: &mimirpb.Metric{
Labels: ts.Labels,
},
})
}
}
}

// Always sort metrics by their labels to make testing simpler.
slices.SortFunc(response.Metric, func(m1, m2 *mimirpb.Metric) int {
slices.SortFunc(response.Metric, func(m1, m2 mimirpb.CustomMetric) int {
return mimirpb.CompareLabelAdapters(m1.Labels, m2.Labels)
})

Expand Down
Loading
Loading