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: inconsistent metric types in mysql #9403

Merged
merged 4 commits into from
Oct 14, 2021

Conversation

fxedel
Copy link
Contributor

@fxedel fxedel commented Jun 21, 2021

Fixed two issues with inconsistent metric types in mysql:

  • mysql variables that are stored as uint64 in mysql and are too big for int64 (currently parsed as float by telegraf)
  • mysql variables with "ON", "OFF" and other string values (currently parsed as integer for "ON"/"OFF" and string otherwise)

The fix included uint parsing (if int fails) and a mapping for some MySQL statuses/variables, pinning them to a specific type.

Note that InfluxDB 1.x doesn't support uint, so outputted values will be capped to max int, but that's a problem with the InfluxDB plugin and not MySQL. (Possible fix: add influxdb option to output uints as floats).

Fixes #8319, #5711, #5055, #7421

See #5529, #6624

This could be easily extended to fix #6671 as well.

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 21, 2021
@fxedel
Copy link
Contributor Author

fxedel commented Jun 21, 2021

!signed-cla

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good codewise, but I have no way of testing this...

@srebhan srebhan self-assigned this Jun 22, 2021
@srebhan srebhan added area/mysql ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. labels Jun 22, 2021
@MyaLongmire
Copy link
Contributor

@eraac @bluebob @bolek2000 This pull request might resolve the issues you opened, if you are still having the issues would you mind testing this fix? #9403 (comment)

@helenosheaa helenosheaa added the waiting for response waiting for response from contributor label Jul 6, 2021
@reimda
Copy link
Contributor

reimda commented Aug 10, 2021

Hi @fxedel I took a quick look at the changes here. I'm a little concerned about backward compatibility. If someone was using "transaction_write_set_extraction" or any of the other ~20 variables which change type because of this PR, they may run into issues. Do you think these fixes would require a new metric_version=3?

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Aug 10, 2021
@fxedel
Copy link
Contributor Author

fxedel commented Aug 14, 2021

Hi @reimda, the issues that could be introduced by this PR are actually the same issues that we're facing today. For example transaction_write_set_extraction is currently stored either as int (when OFF) or string (when MURMUR32) – see #7421. With this PR, it's always stored as string. If the variable has always been set to OFF, it will produce new issues, but, as least for InfluxDB, only until the next shard is created. If the variable has always been changing, the issues were always present and will disappear in future. If the variable has always been set to MURMUR32, there will be no issues.

As this is merely a bug fix, I wouldn't introduce a new metric version, as all users of v2 would benefit in the long-term. A typical shard duration is one week, so InfluxDB users would see no issues after at most seven days.

Of course, a new metric version v3 would also be acceptable.

Copy link
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation, I see what you mean that issues that could be introduced by this PR are actually already happening. I think this change will fix a lot of the existing mysql conversion problems.

I have a couple more questions after looking a little more closely at the code.

plugins/inputs/mysql/v2/convert.go Outdated Show resolved Hide resolved
plugins/inputs/mysql/v2/convert.go Show resolved Hide resolved
@sspaink sspaink changed the title Fix inconsistent metric types in mysql fix: inconsistent metric types in mysql Oct 6, 2021
@srebhan srebhan requested a review from reimda October 12, 2021 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mysql feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
5 participants