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

Crash when iterating table with nil data returned? #110

Closed
srclosson opened this issue Apr 30, 2020 · 7 comments · Fixed by #111
Closed

Crash when iterating table with nil data returned? #110

srclosson opened this issue Apr 30, 2020 · 7 comments · Fixed by #111
Assignees
Labels
bug Something isn't working
Milestone

Comments

@srclosson
Copy link

For some reason, the following scenario causes a crash:

Data returned from influxdb 2.0

	csvRows := []string{
		`#group,false,false,true,true,true,true,true,true,false,false`,
		`#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,double,dateTime:RFC3339`,
		`#default,mean,,,,,,,,,`,
		`,result,table,_start,_stop,_field,_measurement,cpu,host,_value,_time`,
		`,,0,2020-04-30T19:58:15.018029201Z,2020-04-30T20:58:15.018029201Z,usage_guest,cpu,cpu-total,084469dbdc49,,2020-04-30T19:58:20Z`,
		`,,0,2020-04-30T19:58:15.018029201Z,2020-04-30T20:58:15.018029201Z,usage_guest,cpu,cpu-total,084469dbdc49,0,2020-04-30T19:58:30Z`,
		`,,0,2020-04-30T19:58:15.018029201Z,2020-04-30T20:58:15.018029201Z,usage_guest,cpu,cpu-total,084469dbdc49,0,2020-04-30T19:58:40Z`,
		`,,0,2020-04-30T19:58:15.018029201Z,2020-04-30T20:58:15.018029201Z,usage_guest,cpu,cpu-total,084469dbdc49,0,2020-04-30T19:58:50Z`,
		`,,0,2020-04-30T19:58:15.018029201Z,2020-04-30T20:58:15.018029201Z,usage_guest,cpu,cpu-total,084469dbdc49,0,2020-04-30T19:59:00Z`,
	}

To reproduce, simply call
dr := ExecuteQuery(ctx, models.QueryModel{}, runner)

With the csv returned above and the error looks like this:

anic(0xbcd080, 0x134a4b0)
        /go1.14.2/src/runtime/panic.go:969 +0x166
github.com/influxdata/influxdb-client-go.(*FluxTableMetadata).Column(...)
        /go1.14.2/global/pkg/mod/github.com/influxdata/[email protected]/table.go:59
github.com/influxdata/influxdb-client-go.(*QueryTableResult).Next(0xc000246af0, 0xd15d00)
        /go1.14.2/global/pkg/mod/github.com/influxdata/[email protected]/query.go:307 +0x851

I've not looked into it with more detail, but I suspect it has something to do with the face that in the first line of data the value is or empty?

Let me know

@vlastahajek
Copy link
Contributor

@srclosson, such crash has been already fixed in the master with 6ac10dcc.
The flux result parser currently requires the datatype annotation as the first annotation row, and the Query method asks for it.
How did you manage to get such a result?
Do you query on your own and manually use QueryTableResult for parsing?
If yes, just make sure the datatype annotation is the first among annotations

@srclosson
Copy link
Author

That did fix one problem, but there is another. The data was a query returned from influxdb 2.0. Notice the first line, the value column has no value. I expect this is because we used a grouping, and the first value was nil.

The query looks like this:

from(bucket: "grafana")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "cpu")
  |> aggregateWindow(every: v.windowPeriod, fn: mean)
  |> yield(name: "mean")

The error I get now is the strconv.ParseFloat failed.

Ideas?

@vlastahajek vlastahajek added the bug Something isn't working label May 4, 2020
@vlastahajek vlastahajek self-assigned this May 4, 2020
@vlastahajek vlastahajek added this to the v1.2.0 milestone May 4, 2020
@vlastahajek
Copy link
Contributor

It's a bug. Unfortunately, empty values are not yet supported. You can work around this using the fill function in Flux

vlastahajek added a commit to bonitoo-io/influxdb-client-go that referenced this issue May 4, 2020
@vlastahajek
Copy link
Contributor

vlastahajek commented May 4, 2020

You can now try version in the master, where this is fixed.

@srclosson
Copy link
Author

Will try it out.

@srclosson
Copy link
Author

Confrimed @vlastahajek. Thank-you!

@vlastahajek
Copy link
Contributor

Just to let you know, that custom order of annotations is now supported since #134. Only the datatype annotation is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants