-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Only query aurora_version() if aurora postgres extensions are available #20310
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
Conversation
cursor.execute("SELECT * FROM pg_available_extension_versions WHERE name ILIKE '%aurora%' OR comment ILIKE '%aurora%';") | ||
if len(cursor.fetchall()) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to speed up the test (minor nitpick):
- Use
LIMIT 1
to stop scanning after the first row — enough to confirm it’s Aurora. - Use
fetchone
instead offetchall
. - Replace
SELECT *
withSELECT 1
.
Not a blocker - approving the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Needed to fix linting errors on this anyway, so applied the suggested improvements and validated its working correctly on and off Aurora
Review from nenadnoveljic is dismissed. Related teams and files:
- database-monitoring-agent
- postgres/datadog_checks/postgres/version_utils.py
Review from lu-zhengda is dismissed. Related teams and files:
- database-monitoring-agent
- postgres/datadog_checks/postgres/version_utils.py
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
What does this PR do?
Currently the Postgres integration always calls
aurora_version()
to check if the database is running on AWS Aurora. If it's not, the query fails with a function not found error. This leads to query errors in database logs. To avoid calling a function that won't exist outside of AWS Aurora environment, we will now lookup available postgres extensions. If aurora related extensions are available, we can assume we're running in AWS and will verify by querying theaurora_version()
. Changes were made to theVersionUtils.is_aurora()
to cache the results of the first execution as this shouldn't change over the lifetime of the connection.Running this query on Aurora Postgres will return the following extensions
Running it on non Aurora Postgres instances will return zero rows.
Motivation
Review checklist (to be filled by reviewers)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is merged