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

handle string nan results in pool_health_check_stats #14

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

n-oden
Copy link
Contributor

@n-oden n-oden commented Jan 24, 2022

If a node is defined but in status=unused, the average_retry_count
and average_duration columns appear to return a literal string
result of -nan. The result parsing switch correctly returns
math.NaN() in this case, but will return false as the second return
value, leading to errors being logged:

ts=2022-01-24T15:09:10.003Z caller=log.go:168 level=info msg="error parsing" err="Unexpected error parsing column:  pool_health_check_stats average_retry_count [45 110 97 110]\n"
ts=2022-01-24T15:09:10.003Z caller=log.go:168 level=info msg="error parsing" err="Unexpected error parsing column:  pool_health_check_stats average_duration [45 110 97 110]\n"

(45, 110, 97, 110 are the sequential ordinal values for -nan)

Check for a literal value of -nan in the string/byte parsing portion
of dbToFloat64() and return math.NaN(), true, since in this case
we are correctly forwarding a NaN value.

If a node is defined but in status=unused, the `average_retry_count`
and `average_duration` columns appear to return a literal string
result of `-nan`.  The result parsing switch correctly returns
`math.NaN()` in this case, but will return `false` as the second return
value, leading to errors being logged:

```
ts=2022-01-24T15:09:10.003Z caller=log.go:168 level=info msg="error parsing" err="Unexpected error parsing column:  pool_health_check_stats average_retry_count [45 110 97 110]\n"
ts=2022-01-24T15:09:10.003Z caller=log.go:168 level=info msg="error parsing" err="Unexpected error parsing column:  pool_health_check_stats average_duration [45 110 97 110]\n"
```

(45, 110, 97, 110 are the sequential ordinal values for `-nan`)

Check for a literal value of `-nan` in the string/byte parsing portion
of `dbToFloat64()` and return `math.NaN(), true`, since in this case
we are correctly forwarding a NaN value.
@n-oden
Copy link
Contributor Author

n-oden commented Jan 24, 2022

screenshot of the problematic data:

image

@n-oden
Copy link
Contributor Author

n-oden commented Jan 24, 2022

(I poked around in the actual pgpool code and could not immediately suss out why string-nan was being returned in these columns rather than a postgres NaN.)

n-oden added a commit to odenio/pgpool-cloudsql that referenced this pull request Jan 24, 2022
- Cherry-pick pgpool/pgpool2_exporter#14
  into our build of pgpool_exporter

- Build telegraf from source; circle-ci is now 404ing the artifact
  link from influxdata/telegraf#10097 :(

- Bump version to 1.0.5
@pengbo0328
Copy link
Collaborator

Thank you!
You patch fixes the errors.

@pengbo0328 pengbo0328 merged commit b15dd39 into pgpool:master Jan 25, 2022
@n-oden n-oden deleted the handle-string-nan branch January 25, 2022 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants