Skip to content

query: handle query.Analyze returning nil gracefully #8199

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Saumya40-codes
Copy link
Contributor

@Saumya40-codes Saumya40-codes commented Apr 10, 2025

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Should fix #8198

In engine query.Analyze returns nil if query.exec doesn't implements telemetry.ObservableVectorOperator. This PR handles it gracefully as later o/p of it excesses the respective fields

Verification

Not exactly how tagged issue might be stating but if try to analyze the query when its of type [noop] (with query.mode=distributed), the similar type of behaviour occurs (which also gets handled)

Signed-off-by: Saumya Shah <saumyabshah90@gmail.com>
@MichaHoffmann
Copy link
Contributor

In engine query.Analyze returns nil if query.exec doesn't implements telemetry.ObservableVectorOperator. This PR handles it gracefully as later o/p of it excesses the respective fields

can we fix this in the engine? it should not return nil probably

@MichaHoffmann
Copy link
Contributor

It seems like a bug where not all nodes implement

type ObservableVectorOperator interface {
	model.VectorOperator
	OperatorTelemetry
}

@Saumya40-codes
Copy link
Contributor Author

In engine query.Analyze returns nil if query.exec doesn't implements telemetry.ObservableVectorOperator. This PR handles it gracefully as later o/p of it excesses the respective fields

can we fix this in the engine? it should not return nil probably

currently it is

func (q *Query) Analyze() *AnalyzeOutputNode 

ig we change it to return maybe (*AnalyzeOutputNode , error) (err if a node isnt implementing ObservableVectorOperator in case)

@Saumya40-codes
Copy link
Contributor Author

Saumya40-codes commented Apr 12, 2025

It seems like a bug where not all nodes implement

type ObservableVectorOperator interface {
	model.VectorOperator
	OperatorTelemetry
}

Yes, noop operator misses that interface field (rest of what i saw implements it)

type operator struct {
	model.VectorOperator
	// telemetry.OperatorTelemetry <- Needs to be added
}

func NewOperator(opts *query.Options) model.VectorOperator {
	scanner := prometheus.NewVectorSelector(
		model.NewVectorPool(0),
		noopSelector{},
		opts,
		0, 0, false, 0, 1,
	)
	return &operator{VectorOperator: scanner}
}

maybe based on the original issue the below might've got triggered

if len(remoteQueries) == 0 {
	return Noop{}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Querier panic caught by grpc recovery handler when executing a distributed query
2 participants