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

[postgres] FIX: pg8000 wasn't doing a good job with multiple relations #2111

Merged
merged 1 commit into from
Dec 7, 2015

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented Nov 30, 2015

A customer was having issues with the postgres check, after investigating it became apparent that metrics weren't reported for all specified relations. It looks like pg8000 wasn't doing a good job with the parameter substitution when making executing the SQL query.

The fix consists in having us build the query manually instead.

@truthbk
Copy link
Member Author

truthbk commented Dec 1, 2015

Customer confirmed fix is working for them 😄

@@ -437,10 +437,10 @@ def _collect_stats(self, key, db, instance_tags, relations, custom_metrics):
try:
# if this is a relation-specific query, we need to list all relations last
if scope['relation'] and len(relations) > 0:
relnames = relations_config.keys()
relnames = ', '.join("'{0}'".format(w) for w in relations_config.keys())
Copy link

Choose a reason for hiding this comment

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

nitpick but you can use iterkeys instead of keys

…s in list.

[postgres] another query to fix.

[postgres] use iterkeys() to iterate more efficiently.
@truthbk truthbk force-pushed the jaime/postgres-fix branch from a48a078 to 8ec3d4a Compare December 1, 2015 20:21
@truthbk
Copy link
Member Author

truthbk commented Dec 1, 2015

As per @remh comments, switching to iterkeys() for dict iteration.

@olivielpeau olivielpeau added this to the 5.6.3 milestone Dec 4, 2015
@olivielpeau
Copy link
Member

LGTM!

truthbk added a commit that referenced this pull request Dec 7, 2015
[postgres] FIX: pg8000 wasn't doing a good job with multiple relations
@truthbk truthbk merged commit 94894bf into master Dec 7, 2015
@truthbk truthbk deleted the jaime/postgres-fix branch December 7, 2015 16:10
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.

3 participants