Repository navigation
[Mocha] Fix PostgreSQL outbox and scheduling authentication with NpgsqlDataSource - #10477
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation addresses the authentication regression while preserving connection ownership and covering the relevant configurations and lifecycle behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes PostgreSQL outbox authentication by preserving the EF Core context’s Npgsql configuration when creating worker connections.
Changes:
- Replaces connection-string reconstruction with cloned dedicated connections.
- Adds safe connection-failure logging and reliable disposal.
- Adds integration coverage for authentication, retries, pooling, transactions, and ownership.
| File | Description |
|---|---|
PostgresOutboxWorkerAuthenticationTests.cs |
Adds PostgreSQL authentication and lifecycle tests. |
OutboxServiceRegistrationTests.cs |
Verifies the connection factory configuration. |
PostgresMessageOutboxOptions.cs |
Replaces the connection string with a connection factory. |
OutboxServiceCollectionExtensions.cs |
Clones the configured Npgsql connection. |
MessageBusOutboxWorker.cs |
Uses, logs, retries, and disposes dedicated connections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tobias-tengler
marked this pull request as draft
October 4, 2026 10:12
Contributor
Patch coverage100.0% of changed lines covered (75/75)
Project coverage: 58.5% (313773/536038 lines) |
tobias-tengler
force-pushed
the
fix/postgres-outbox-worker-auth
branch
from
October 6, 2026 15:30
527151e to
38fa19f
Compare
tobias-tengler
marked this pull request as ready for review
October 6, 2026 16:16
PascalSenn
approved these changes
Oct 6, 2026
This was referenced Oct 25, 2026
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When EF Core uses an
NpgsqlDataSource, the PostgreSQL outbox and scheduling workers rebuild their data source from a connection string that omits the password by default (Persist Security Info=false). This loses credentials and authentication callbacks, causing authentication failures and leaving committed and scheduled messages undelivered. Both workers also keep a connection open while idle.This PR clones the context's configured connection and reuses it while draining due messages, preserving authentication and data source settings. The connection and scope are disposed before idle waits, leaving the configured data source intact.