Skip to content

fix Postgres diagnose conn handling#23602

Merged
eric-weaver merged 4 commits intomasterfrom
eric.weaver/fix-diagnose-conn-handling
May 6, 2026
Merged

fix Postgres diagnose conn handling#23602
eric-weaver merged 4 commits intomasterfrom
eric.weaver/fix-diagnose-conn-handling

Conversation

@eric-weaver
Copy link
Copy Markdown
Contributor

What does this PR do?

  • Fixes a potential connection leak when PostgreSql._new_connection() successfully opens a connection but then fails to configure the connection with our expected initialization SET commands.
  • Fixes surfacing connection errors in diagnose.py when opening a connection and receives an authentication error from AWS or Azure managed providers.

Motivation

Follow up from #23433

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 Bot commented May 5, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 92.99% (+5.76%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 803331a | Docs | Datadog PR Page | Give us feedback!

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.39%. Comparing base (0e82485) to head (803331a).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

… probes

Replace `_fetchone` (which swallows psycopg.Error and returns None) with
direct cursor calls in `_diagnose_version` and `_diagnose_pg_monitor_role`
so transient errors during `SHOW SERVER_VERSION`, `SELECT ... pg_roles`,
or `pg_has_role` produce a FAIL with the actual psycopg message instead
of `'NoneType' object is not subscriptable`, a silent skip mistaken for
PG < 10, or a misleading "not a member of pg_monitor" with a GRANT
remediation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelmarcotte
Copy link
Copy Markdown
Contributor

@codex review

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 5, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@eric-weaver eric-weaver enabled auto-merge May 5, 2026 19:42
@eric-weaver eric-weaver added this pull request to the merge queue May 6, 2026
Merged via the queue into master with commit 594ee98 May 6, 2026
71 checks passed
@eric-weaver eric-weaver deleted the eric.weaver/fix-diagnose-conn-handling branch May 6, 2026 17:29
@dd-octo-sts dd-octo-sts Bot added this to the 7.79.0 milestone May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants