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

fix(httpd): Fixes key collisions when serializing /debug/vars #18004

Merged
merged 1 commit into from
May 7, 2020

Conversation

stuartcarnie
Copy link
Contributor

This PR fixes an issue with serveExpvar so that it does not generate invalid JSON. Specifically, the improvement was made to prevent key collisions when serializing []*monitor.Statistic values.

The algorithm works as such:

  1. record each statistic key in a map with a count of occurrences
  2. if the count > 0, amend key with the suffix :<count>

In practice, key collisions for hh_processor were observed with Enterprise:

  "hh:/var/lib/influxdb/hh": {"name":"hh",
  "hh_processor": {"name":"hh_processor","tags":{"db"
  "hh_processor": {"name":"hh_processor","tags":{"db"
  "hh_processor": {"name":"hh_processor","tags":{"db"
  "hh_processor": {"name":"hh_processor","tags":{"db"
  "hh_database": {"name":"hh_database","tags":{"db"

This change will serialize these values as:

  "hh:/var/lib/influxdb/hh": {"name":"hh",
  "hh_processor": {"name":"hh_processor","tags":{"db"
  "hh_processor:1": {"name":"hh_processor","tags":{"db"
  "hh_processor:2": {"name":"hh_processor","tags":{"db"
  "hh_processor:3": {"name":"hh_processor","tags":{"db"
  "hh_database": {"name":"hh_database","tags":{"db"

@stuartcarnie stuartcarnie force-pushed the sgc/fix/unique_keys branch from 2d11f60 to 280d271 Compare May 7, 2020 18:25
@stuartcarnie stuartcarnie requested a review from benbjohnson May 7, 2020 18:26
dgnorton
dgnorton previously approved these changes May 7, 2020
Copy link
Contributor

@dgnorton dgnorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@stuartcarnie stuartcarnie merged commit 0cb09dd into master-1.x May 7, 2020
@stuartcarnie stuartcarnie deleted the sgc/fix/unique_keys branch May 7, 2020 19:39
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.

2 participants