Skip to content

Fix Postgres health checks with Postgres 18#17558

Open
PatrickMatthiesen wants to merge 1 commit into
microsoft:mainfrom
PatrickMatthiesen:codex/fix-postgres18-healthcheck-npgsql
Open

Fix Postgres health checks with Postgres 18#17558
PatrickMatthiesen wants to merge 1 commit into
microsoft:mainfrom
PatrickMatthiesen:codex/fix-postgres18-healthcheck-npgsql

Conversation

@PatrickMatthiesen
Copy link
Copy Markdown

Summary

  • add an explicit Npgsql dependency to Aspire.Hosting.PostgreSQL
  • centrally pin Npgsql to 10.0.2, matching the existing Npgsql.DependencyInjection version
  • ensure the built-in Postgres healthcheck no longer resolves to Npgsql 8.0.3 when using the default postgres:18.3 image

Details

Aspire.Hosting.PostgreSQL registers its server healthcheck through AspNetCore.HealthChecks.NpgSql 9.0.0. Without a direct Npgsql dependency, that package resolves Npgsql 8.0.3.

After the default Postgres image moved from postgres:17.6 to postgres:18.3, the Npgsql 8.0.3 healthcheck can time out even while the container is running and accepting connections. When postgres_check never becomes healthy, the Postgres ResourceReadyEvent is not published, so the AddDatabase(...) creation hook does not run and child database resources can remain missing/unhealthy.

Local repro evidence against postgres:18.3:

  • direct Npgsql 8.0.3 connection timed out
  • AspNetCore.HealthChecks.NpgSql 9.0.0 with transitive Npgsql 8.0.3 reported unhealthy
  • direct Npgsql 9.0.5 / 10.0.1 connections succeeded
  • AspNetCore.HealthChecks.NpgSql 9.0.0 with explicit newer Npgsql reported healthy

Testing

dotnet test --project tests/Aspire.Hosting.PostgreSQL.Tests/Aspire.Hosting.PostgreSQL.Tests.csproj -- --filter-method "*PostgresFunctionalTests.VerifyPostgresResource" --filter-method "*PostgresFunctionalTests.AddDatabaseCreatesDatabaseResiliently"

Passed: total 2, failed 0, succeeded 2

Copilot AI review requested due to automatic review settings May 27, 2026 20:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a direct package reference to Npgsql in the Aspire.Hosting.PostgreSQL project, along with the corresponding centralized package version entry.

Changes:

  • Added Npgsql 10.0.2 entry to Directory.Packages.props.
  • Added a PackageReference to Npgsql in Aspire.Hosting.PostgreSQL.csproj.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Directory.Packages.props Registers centrally-managed Npgsql version 10.0.2.
src/Aspire.Hosting.PostgreSQL/Aspire.Hosting.PostgreSQL.csproj Adds direct Npgsql package dependency to the PostgreSQL hosting project.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17558

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17558"

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.

2 participants