Skip to content

Per-tenant managed partitioning parity with Marten (documents + streams) #335

Description

@jeremydmiller

Follow-up epic to the Wolverine conjoined EF Core multi-tenancy epic (JasperFx/wolverine#3465). Depends on the Weasel parity work in JasperFx/weasel#362.

Polecat supports Weasel ManagedTenantPartitions for the events table only (UseTenantPartitionedEvents, #163/#171, with per-tenant sequences via TenantEventSequenceRegistry). Marten's per-tenant partitioning goes further, and Polecat should reach full equivalence:

Gaps vs Marten today

  • Document tables: conjoined documents are tenant_id column + filter only. DocumentTable explicitly throws when partitioning is combined with conjoined tenancy ("RANGE partitioning of document tables is currently supported for single-tenant tables only"). Marten offers managed tenant partitioning on all conjoined document tables.
  • Streams table: Marten partitions mt_streams alongside mt_events under UseTenantPartitionedEvents; audit what pc_streams does and bring it in line.
  • Policy APIs: no equivalents of Marten's AllDocumentsAreMultiTenantedWithPartitioning(...) / PartitionMultiTenantedDocumentsUsingMartenManagement(...).
  • Runtime tenant onboarding: no equivalent of store.Advanced.AddMartenManagedTenantsAsync(...) / RemoveMartenManagedTenantsAsync(...) returning TablePartitionStatus[], nor the reserved default-tenant partition Marten auto-provisions for global projections.

Proposed scope

  1. Lift the DocumentTable restriction: managed tenant partitioning for conjoined document tables (tenant_ordinal column + the store's shared ManagedTenantPartitions feature, one registry per database).
  2. Partition the streams table to match the events table under UseTenantPartitionedEvents.
  3. Policy-level API parity (naming TBD, mirroring Marten's shapes).
  4. Runtime API parity: store.Advanced.AddPolecatManagedTenantsAsync(...) / Remove... with per-table status returns; reserved default-tenant partition if the Marten global-projection behavior applies.
  5. Define tenant-removal data semantics — SQL Server MERGE RANGE does not remove the tenant's rows (see ManagedTenantPartitions (SQL Server) parity with ManagedListPartitions: drop semantics, bucketing, back-fill weasel#362 item 1).

This epic is the prerequisite for CritterWatch's SQL Server hard-delete support (JasperFx/CritterWatch#68).

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