Parallelize tenant database initialization in EnsureAllTenantDatabasesCreatedAsync#2482
Merged
jeremydmiller merged 3 commits intomainfrom Apr 9, 2026
Merged
Conversation
Replace culture-sensitive ToLower() with ToLowerInvariant() in all SQL identifier normalization paths. In Turkish locale, 'I'.ToLower() produces dotless 'ı' instead of 'i', corrupting SQL names such as queue/table identifiers used in envelope storage. Affects SqlServerTransport, PostgresqlTransport, MySqlTransport, SqliteTransport, and SagaTableDefinition. Adds a regression test that verifies SanitizeIdentifier behaves correctly under tr-TR culture. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`PullSagaIdFromEnvelopeFrame` used `NameInCode()` (bare type name) when emitting `TryParse` calls for non-Guid saga ID types. For strong-typed identifiers in a custom namespace this produced unresolvable type references (CS0103/CS0246) in the generated handler code. Changed to `FullNameInCode()` so the fully qualified type name is always emitted, matching the approach already used in `PullSagaIdFromMessageFrame` for its strong-typed-ID path. Added a regression test (`Bug_2465_strong_typed_id_saga_codegen`) that uses a `record struct StrongSagaId(Guid)` with a `TryParse` method and verifies that the host starts (code generation succeeds) and that messages routed through the envelope path are handled correctly. Also added a "Strong-Typed Identifiers" documentation section in sagas.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sCreatedAsync (#2477) Replace sequential foreach loops in TenantedDbContextBuilderByConnectionString and TenantedDbContextBuilderByDbDataSource with Parallel.ForEachAsync (MaxDegreeOfParallelism=10), reducing startup time for deployments with many tenants. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 11, 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.
Fixes #2477
Summary
foreachloops inEnsureAllTenantDatabasesCreatedAsync()withParallel.ForEachAsync(MaxDegreeOfParallelism=10) in bothTenantedDbContextBuilderByConnectionStringandTenantedDbContextBuilderByDbDataSourceDetails
The previous implementation processed tenants one at a time, causing significant startup delays for deployments with 100+ tenants. With
Parallel.ForEachAsync, up to 10 databases can be initialized concurrently, dramatically reducing startup time.Error handling is preserved: if any tenant initialization fails, the exception propagates via the returned
Task, consistent with the previous behavior of stopping on the first error.Test plan
parallel_tenant_initialization_tests.csverify all tenants processed, concurrent execution is faster than sequential, and failures surface as exceptionsEfCoreTests.MultiTenancycover end-to-end tenant initialization🤖 Generated with Claude Code