Skip to content

ManagedTenantPartitions (SQL Server) parity with ManagedListPartitions: drop semantics, bucketing, back-fill #362

Description

@jeremydmiller

Part of the Wolverine conjoined EF Core multi-tenancy epic (JasperFx/wolverine#3465).

ManagedTenantPartitions (built for Polecat's UseTenantPartitionedEvents, #301) is currently applied to a single table per store. The Wolverine conjoined EF Core tenancy epic and the Polecat document/streams partitioning follow-up will apply it across many tables per application, and CritterWatch tenant management (add/remove/hard-delete) will drive it at runtime. Before that, close the gaps against the mature Postgres ManagedListPartitions feature set:

Gaps

  1. Data-removing drop semantics. Postgres managed drop is DETACH PARTITION [CONCURRENTLY] + DROP TABLE — the tenant's rows are physically removed. SQL Server's DropPartitionFromAllTables issues ALTER PARTITION FUNCTION … MERGE RANGE, which removes the boundary but merges the tenant's rows into the neighboring partition. Removing a tenant should (at least optionally) delete that tenant's rows before merging, or the contract must clearly state the caller owns the purge. Needed for CritterWatch RemoveTenant/hard-delete parity on SQL Server.

  2. Tenant bucketing (many tenants → one partition). Postgres partition_value → partition_suffix mapping is many-to-one by design, so small tenants can share a partition. SQL Server ordinal allocation is strictly max + 1 per tenant with no sharing. Add optional explicit ordinal assignment on add (AddPartitionToAllTables(tenantId, ordinal)-shaped) so multiple tenant ids can map to one ordinal/partition. This is also the mitigation for SQL Server's 15,000-partition ceiling.

  3. New-table back-fill under migration. The Postgres additive path has explicit handling so a table newly wired to an existing ManagedListPartitions gets all existing partitions created. TableDelta on SQL Server deliberately skips managed strategies — verify (and cover with tests) that a table newly added to an existing managed set is split for all existing tenant ordinals when migrated.

  4. Batch add / status reporting parity. Postgres batch AddPartitionToAllTables(logger, database, dictionary) returns TablePartitionStatus[] per table. Confirm the SQL Server overloads report equivalent per-table status so callers (Wolverine, Polecat, CritterWatch) can surface partial failures.

No change proposed for disabled-tenant awareness — tenant lifecycle state deliberately stays in the consuming library's registry, not Weasel's partition control tables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions