Add sharded multi-tenancy with database pooling#4211
Merged
jeremydmiller merged 5 commits intomasterfrom Mar 27, 2026
Merged
Conversation
New ShardedTenancy ITenancy implementation that: - Distributes tenants across a pool of databases (mt_database_pool) - Tracks tenant-to-database assignments (mt_tenant_assignments) - Creates native PG LIST partitions per tenant within each database - Supports 3 assignment strategies: hash, smallest, explicit - Uses advisory locks for concurrent-safe tenant assignment - Provides admin API (AddTenantToShardAsync, AddDatabaseToPoolAsync, etc.) Weasel abstractions (ITenantDatabasePool, ITenantAssignmentStrategy, IDatabaseSizingStrategy) enable other CritterStack tools to manage tenants. 8/12 integration tests passing. Remaining 4 need schema migration ordering fix for partition table creation in shard databases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fixed schema cleanup: ensure public schema exists before dropping mt_ objects - Fixed MarkDatabaseFullAsync: seed databases before marking full so the pool row exists when the UPDATE runs - Fixed findOrAssignTenantDatabaseAsync: seed databases before auto-assignment so the available database list is populated - All 128 MultiTenancyTests pass including existing managed partitioning, bucketed sharding, and master table tenancy tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New section in multitenancy.md covering: - Configuration with MultiTenantedWithShardedDatabases() - Three assignment strategies: hash, smallest, explicit (with custom) - Database registry tables (mt_database_pool, mt_tenant_assignments) - Admin API for runtime tenant/database management - Implicit vs explicit tenant assignment flow - Async daemon integration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Revert ProjectReference to PackageReference for Weasel.Postgresql - Update Weasel.Postgresql and Weasel.EntityFrameworkCore to 8.11.0 - Remove lib/weasel submodule and .gitmodules - All 128 MultiTenancyTests pass (including 12 sharded tenancy tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- MD004: switch unordered lists from dashes to asterisks - MD060: add spaces in table separator rows for proper pipe spacing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
The tests all pass locally, we've got some kind of hopefully temporary Docker issue on GH actions |
This was referenced Mar 30, 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.
Summary
ShardedTenancyITenancy implementation for extreme scalability (targeting 200B+ events)mt_database_pool,mt_tenant_assignments) in master databaseAddTenantToShardAsync,AddDatabaseToPoolAsync,MarkDatabaseFullAsyncMultiTenantedWithShardedDatabases()docs/configuration/multitenancy.mdTest plan
🤖 Generated with Claude Code