Skip to content

Prevent concurrent database health checks from sharing a single connection - #1733

Open
TimHess wants to merge 1 commit into
build-4.3.0from
fix/db-health-contributor-concurrency
Open

Prevent concurrent database health checks from sharing a single connection#1733
TimHess wants to merge 1 commit into
build-4.3.0from
fix/db-health-contributor-concurrency

Conversation

@TimHess

@TimHess TimHess commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

  • Update RelationalDatabaseHealthContributor to take a connection factory so each health check manages its own connection, avoiding overlapping checks opening and closing the same connection at the same time.
  • Pass the database type name directly to skip reflection.

Fixes #1732

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation and/or Samples, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@TimHess TimHess added the Component/Connectors Issues related to Steeltoe connectors label Aug 21, 2026
@TimHess TimHess added this to the 4.3.0 milestone Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Summary - All Code Coverage (ubuntu-latest)

Line coverage Branch coverage

Assembly Line coverage Branch coverage
Steeltoe.Bootstrap.AutoConfiguration 97.4% 83.3%
Steeltoe.Common 86.4% 77%
Steeltoe.Common.Certificates 97.2% 80.2%
Steeltoe.Common.Hosting 83.5% 65%
Steeltoe.Common.Http 97.4% 80.9%
Steeltoe.Common.Logging 81.1% 56.2%
Steeltoe.Common.Net 64.5% 66.6%
Steeltoe.Configuration.Abstractions 96.3% 89.4%
Steeltoe.Configuration.CloudFoundry 98.4% 92.7%
Steeltoe.Configuration.ConfigServer 91.6% 86.2%
Steeltoe.Configuration.Encryption 97.6% 87.8%
Steeltoe.Configuration.Kubernetes.ServiceBindings 95.6% 82.6%
Steeltoe.Configuration.Placeholder 93.8% 82.6%
Steeltoe.Configuration.RandomValue 93.2% 83.3%
Steeltoe.Configuration.SpringBoot 98.3% 85%
Steeltoe.Connectors 94.4% 85.3%
Steeltoe.Connectors.EntityFrameworkCore 81% 65.3%
Steeltoe.Discovery.Configuration 96.3% 75%
Steeltoe.Discovery.Consul 91.5% 84%
Steeltoe.Discovery.Eureka 89.8% 80.6%
Steeltoe.Discovery.HttpClients 89.9% 91.4%
Steeltoe.Logging.Abstractions 99.4% 95.6%
Steeltoe.Logging.DynamicConsole 100% 92.3%
Steeltoe.Logging.DynamicSerilog 99.1% 95.4%
Steeltoe.Management.Abstractions 100% 100%
Steeltoe.Management.Endpoint 96% 87.1%
Steeltoe.Management.GitProperties.Build 95.1% 83.9%
Steeltoe.Management.Prometheus 95.8% 76.9%
Steeltoe.Management.Tasks 95.2% 80%
Steeltoe.Management.Tracing 100% 75%
Steeltoe.Security.Authentication.JwtBearer 100% 93.7%
Steeltoe.Security.Authentication.OpenIdConnect 87.7% 66.6%
Steeltoe.Security.Authorization.Certificate 95.6% 61.5%
Steeltoe.Security.DataProtection.Redis 100% ****

- Update RelationalDatabaseHealthContributor to take a connection factory so each health check manages its own connection, avoiding overlapping checks opening and closing the same connection at the same time.
- Pass the database type name directly to skip reflection.

Co-Authored-By: Claude <noreply@anthropic.com>
@TimHess
TimHess force-pushed the fix/db-health-contributor-concurrency branch from 6dac9d4 to a00b2c8 Compare August 21, 2026 19:50
@TimHess
TimHess marked this pull request as ready for review August 21, 2026 19:59
@sonarqubecloud

Copy link
Copy Markdown

@TimHess
TimHess requested a review from bart-vmware August 21, 2026 21:46
}

[Fact]
public async Task Concurrent_Health_Checks_Use_Independent_Connections()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this test should be removed. It is highly complicated and basically proves nothing, because it is up to the code calling the constructor whether the DbConnection is shared or not.

@bart-vmware bart-vmware left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, except for the added test.

@bart-vmware

Copy link
Copy Markdown
Member

This PR targets another PR. Please rebase on main, so it can be merged independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component/Connectors Issues related to Steeltoe connectors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants