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

[MySQL] Adds another option for innodb aio reads and writes #660

Merged
merged 12 commits into from
Aug 18, 2017

Conversation

nmuesch
Copy link
Collaborator

@nmuesch nmuesch commented Aug 7, 2017

What does this PR do?

Adds another format option to the mysql innodb aio reads and writes output.

Motivation

Customer reached out using MySQL 5.5.38, with the output of SHOW INNODB STATUS of:

Pending normal aio reads: 0 [0, 0, 0, 0, 0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,

Also takes from @derekwbrown's update to ensure we don't crash in the future when new formats arise.

Testing Guidelines

An overview on testing
is available in our contribution guidelines.

Versioning

  • Bumped the version check in manifest.json
  • Updated CHANGELOG.md

Additional Notes

Anything else we should know when reviewing?

@bits-bot
Copy link
Collaborator

bits-bot commented Aug 7, 2017

@nmuesch, thanks for your PR! By analyzing the history of the files in this pull request, we identified @gmmeyer, @truthbk and @yannmh to be potential reviewers.

@truthbk truthbk self-requested a review August 11, 2017 13:09
truthbk
truthbk previously approved these changes Aug 11, 2017
Copy link
Member

@truthbk truthbk 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, would just like to see a comment at the top of the if-block to now what we may expect of the newfound format.

mysql/check.py Outdated
@@ -1023,6 +1023,9 @@ def _get_stats_from_innodb_status(self, db):
elif len(row) == 18:
results['Innodb_pending_normal_aio_reads'] = long(row[4])
results['Innodb_pending_normal_aio_writes'] = long(row[12])
elif len(row) == 22:
Copy link
Member

Choose a reason for hiding this comment

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

could you please add the format in the commented section above.... Man there are way too many formats 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done 🙂

@@ -45,3 +52,45 @@
[#291]: https://github.com/DataDog/integrations-core/issues/291
[#329]: https://github.com/DataDog/integrations-core/issues/329
[#394]: https://github.com/DataDog/integrations-core/issues/394
[#660]: https://github.com/DataDog/integrations-core/pull/660
Copy link
Member

Choose a reason for hiding this comment

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

Small bug in edition here: duplicate file after footer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry about that one, copy/paste failed me. Will be more careful on that. Should be good now

mysql/check.py Outdated
@@ -891,6 +891,12 @@ def _get_slave_status(self, db, above_560, nonblocking):
self.warning("Privileges error accessing the process tables (must grant PROCESS): %s" % str(e))
return {}

def _are_values_numeric(self, array):
for v in array:
Copy link
Member

Choose a reason for hiding this comment

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

the all func does that:

return all([v.isdigit() for v in array])

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

I think we can make this a little cleaner just by harnessing the ValueError exceptions that could arise. Let me know how you feel about it @nmuesch

mysql/check.py Outdated
results['Innodb_pending_normal_aio_writes'] = long(row[10])
if len(row) == 8:
# (len(row) == 8) Pending normal aio reads: 0, aio writes: 0,
if row[4].isdigit() and row[7].isdigit():
Copy link
Member

Choose a reason for hiding this comment

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

It's nice that you did this, but I don't think you really needed to ;)

The actual long(row[n]) will raise a ValueError if we can't parse to a long. So wrapping this entire Pending normal aio reads in a try...except ValueError would've probably sufficed. 😅

This would probably apply to all the blocks below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only issue of doing the entire surrounding try/except is that we are coming to the point where multiple len==16 return different output. So we would have to check if some values were a digit anyway. (Also this code came from @derekwbrown after our discussion, can't take the credit :) )

Copy link
Contributor

Choose a reason for hiding this comment

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

@nmuesch Originally did this as you suggest; but on only one if. I suggested this as a way to catch new formats going forward. Could also wrap the entire section in try...except i suppose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, discussed further. Will do a combination of the two approaches to be cleaner/less lines :)

mysql/check.py Outdated
long(row[13]) + long(row[14]))
# (len(row) == 16) Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
if self._are_values_numeric(row[4:8]) and self._are_values_numeric(row[11:15]):
results['Innodb_pending_normal_aio_reads'] = (long(row[4]) + long(row[5]) +
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this fail for row[4]: long('[0') for example? I think we have to sanitize that:
eg. long(row[4].strip('['))

Similarly, for row[7]: long(row[7]) ---> long(row[7].strip(']'))

Copy link
Member

Choose a reason for hiding this comment

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

hush-hush
hush-hush previously approved these changes Aug 18, 2017
truthbk
truthbk previously approved these changes Aug 18, 2017
Copy link
Member

@truthbk truthbk 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! Thanks @nmuesch :shipit:

@nmuesch nmuesch added this to the 5.17 milestone Aug 18, 2017
@nmuesch nmuesch merged commit 61697e6 into master Aug 18, 2017
@nmuesch nmuesch deleted the nick/mysql_innodb_aio_reads_writes_format_update branch August 18, 2017 19:56
gml3ff pushed a commit that referenced this pull request May 14, 2020
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.

6 participants