Fix mysql metric for innodb row lock time #7289
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Previously, the code retrieved the internal innodb metric returned by
SHOW STATUS
first, and then tried to add the row lock time from anyin-flight query on top of it, based on
SHOW ENGINE INNODB STATUS
.The intention was probably to make the metric more accurate, because
the internal innodb metric for row lock time will only be incremented
once a query has completed (either successfully or after exceeding
innodb_lock_wait_timeout
).However, the addition actually didn't work, because we are just merging
2 python dictionaries. So, we would end up with either the accumulating
counter value from
SHOW STATUS
when there is no in-flight querywaiting for row lock, or the manually calculated value from parsing
SHOW ENGINE INNODB STATUS
otherwise. Flipping between these 2 values,the rate calculated by datadog agent would be useless and confusing.
This is fixed by returning the internal innodb metric as-is. Trying to
add the row lock time from in-flight queries would introduce complexity
without adding much benefit, as the default
innodb_lock_wait_timeout
is only 50 seconds anyway.
Motivation
The wrong metric made the graph looks confusing, and also prevented us from setting the alert threshold.
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached