Skip to content

Commit

Permalink
MQE: Fix handling of string results (#9803)
Browse files Browse the repository at this point in the history
This would previously panic after the query was closed
  • Loading branch information
jhesketh authored Nov 4, 2024
1 parent 1ddb580 commit dcbf3f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/streamingpromql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ func TestNewInstantQuery_Strings(t *testing.T) {
q, err := mimirEngine.NewInstantQuery(ctx, storage, nil, expr, time.Now())
require.NoError(t, err)
mimir := q.Exec(context.Background())
q.Close()

q, err = prometheusEngine.NewInstantQuery(ctx, storage, nil, expr, time.Now())
require.NoError(t, err)
prometheus := q.Exec(context.Background())
q.Close()

testutils.RequireEqualResults(t, expr, prometheus, mimir)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/streamingpromql/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ func (q *Query) Close() {
types.VectorPool.Put(v, q.memoryConsumptionTracker)
case promql.Scalar:
// Nothing to do, we already returned the slice in populateScalarFromScalarOperator.
case promql.String:
// Nothing to do as strings don't come from a pool
default:
panic(fmt.Sprintf("unknown result value type %T", q.result.Value))
}
Expand Down

0 comments on commit dcbf3f4

Please sign in to comment.