Implement Polecat primary-store database-per-tenant (GH-3445)#3452
Merged
Conversation
The primary Polecat IntegrateWithWolverine() path unconditionally built a single non-tenanted SqlServerMessageStore and never read PolecatIntegration.MainDatabaseConnectionString, so under a database-per-tenant Polecat store the tenant envelopes silently went to the wrong database — a no-op, not an error. Mirror the ancillary Polecat path (and the Marten twin in WolverineOptionsMartenExtensions): dispatch on tenancy cardinality and, for a multi-tenanted store, build a MultiTenantedMessageStore over a PolecatMessageDatabaseSource with a Role.Main master store for tenant-neutral state, reading MainDatabaseConnectionString. Cardinality is checked rather than the tenancy's type name (see the ancillary seam's marten#4864 note). Test: primary_store_database_per_tenant proves the primary store is now a MultiTenantedMessageStore and durability agents exist for each tenant database. Verified red against origin/main, green with the fix. Docs: fix the multi-tenancy sample to use Polecat's AddTenant(tenantId, conn) instead of Marten's AddSingleTenantDatabase(conn, tenantId), and correct the distribution page's agent-URI example — Polecat's IEventStore.Identity.Type is its storage engine "SqlServer" (lowercased in the URI), not "polecat". Also bump Weasel 9.16.4 -> 9.17.0 and the Polecat floor to 5.1.0 (latest). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #3445.
The gap
PolecatIntegration.MainDatabaseConnectionStringwas documented on the Polecat multi-tenancy page as the way to point Wolverine's envelope storage at a master database under database-per-tenant — but nothing read it. The primaryIntegrateWithWolverine()path (WolverineOptionsPolecatExtensions.cs) unconditionally built a single non-tenantedSqlServerMessageStorefromstore.Options.ConnectionString, with no cardinality branch and noMultiTenantedMessageStore. Because it's a silent no-op rather than a compile error, a user following the docs shipped a system whose tenant messages went to the wrong store.The
PolecatMessageDatabaseSource/MultiTenantedMessageStoremachinery already existed — but only on the ancillary path. Marten's primary path has always had the branch (WolverineOptionsMartenExtensions.cs:126-140).The fix
Mirror the ancillary Polecat path and the Marten twin on the primary path:
store.Options.Tenancy.Cardinality(not the tenancy type name — see the ancillary seam's marten#4864 note).MultiTenantedMessageStoreover aPolecatMessageDatabaseSourcewith aRole.Mainmaster store for tenant-neutral state (nodes, assignments, dead letters), readingMainDatabaseConnectionString(falling back to the store's base connection string, throwing a clear error if neither is present).Tests
primary_store_database_per_tenant(SQL Server) asserts the primary store is now aMultiTenantedMessageStoreand that durability agents exist for each tenant database. Verified red againstorigin/main, green with the fix.Docs (items 2 & 3 from the issue)
AddSingleTenantDatabase(conn, tenantId); corrected to Polecat'sAddTenant(tenantId, conn)(reversed args).IEventStore.Identity => new(StoreName.ToLowerInvariant(), "SqlServer")andEventStoreIdentity(string Name, string Type), soUriForemits{Type}/{Name}=sqlserver/main, notpolecat/main.Dependencies
Bumps Weasel
9.16.4 -> 9.17.0and the Polecat floor to5.1.0(both latest on NuGet). Fullwolverine.slnxbuilds clean in Release.🤖 Generated with Claude Code