Skip to content

Add repro for Marten issue 4268#2566

Closed
erdtsieck wants to merge 2 commits intoJasperFx:mainfrom
erdtsieck:bugfix/4268
Closed

Add repro for Marten issue 4268#2566
erdtsieck wants to merge 2 commits intoJasperFx:mainfrom
erdtsieck:bugfix/4268

Conversation

@erdtsieck
Copy link
Copy Markdown
Contributor

Reproduction of JasperFx/marten#4268

erdtsieck and others added 2 commits April 22, 2026 13:52
… / marten#4268)

Wolverine's Envelope outbox document was silently picking up blanket
document policies applied to a store — most painfully
options.Policies.AllDocumentsAreMultiTenantedWithPartitioning. That
turned mt_doc_envelope into a hash-partitioned, conjoined-tenant table.
When a second store sharing the same schema described Envelope as
single-tenant (its normal default, since Wolverine never asks for
multi-tenancy on its own operational table), Marten's schema diff
emitted an impossible delta:

    drop constraint pkey_mt_doc_envelope_id_tenant_id CASCADE;
    add CONSTRAINT pkey_mt_doc_envelope_id PRIMARY KEY (id);  -- 0A000
    drop column tenant_id;

Postgres rejects the ADD PRIMARY KEY on a still-partitioned table with
"unique constraint on partitioned table must include all partitioning
columns". Async projections hid the conflict; inline projections surface
it on the first SaveChanges.

MartenOverrides.Configure now pins Envelope as single-tenant /
unpartitioned via Schema.For<Envelope>().SingleTenanted().DoNotPartition().
Those alterations land on the DocumentMappingBuilder<T> _alterations
list, which fires AFTER applyPolicies + applyPostPolicies during
DocumentMapping construction, so blanket ForAllDocuments policies can't
override them.

Updated the reproducer from JasperFx#2566 to assert the new guarantee: Envelope
is NOT tenant-partitioned after the async-projection store runs, and the
subsequent inline-side-effects store does not throw
MartenSchemaException on its first SaveChanges.

Verification:
- Bug_4268 reproducer: 1/1 pass (was failing pre-fix)
- MartenTests subset (Bugs + MartenOutbox + publish_messages + AncillaryStores): 52/52 pass
- Wolverine CoreTests: 1346/1346 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller
Copy link
Copy Markdown
Member

Superseded by #2570 — same change set against the JasperFx fork so it can be merged directly. Your reproducer commit is preserved with full authorship attribution. Thanks for the targeted repro!

jeremydmiller added a commit that referenced this pull request Apr 22, 2026
…t-pin

Exempt Wolverine's Envelope from blanket multi-tenant doc policies (supersedes #2566 / marten#4268)
erikshafer pushed a commit to erikshafer/wolverine that referenced this pull request Apr 23, 2026
… / marten#4268)

Wolverine's Envelope outbox document was silently picking up blanket
document policies applied to a store — most painfully
options.Policies.AllDocumentsAreMultiTenantedWithPartitioning. That
turned mt_doc_envelope into a hash-partitioned, conjoined-tenant table.
When a second store sharing the same schema described Envelope as
single-tenant (its normal default, since Wolverine never asks for
multi-tenancy on its own operational table), Marten's schema diff
emitted an impossible delta:

    drop constraint pkey_mt_doc_envelope_id_tenant_id CASCADE;
    add CONSTRAINT pkey_mt_doc_envelope_id PRIMARY KEY (id);  -- 0A000
    drop column tenant_id;

Postgres rejects the ADD PRIMARY KEY on a still-partitioned table with
"unique constraint on partitioned table must include all partitioning
columns". Async projections hid the conflict; inline projections surface
it on the first SaveChanges.

MartenOverrides.Configure now pins Envelope as single-tenant /
unpartitioned via Schema.For<Envelope>().SingleTenanted().DoNotPartition().
Those alterations land on the DocumentMappingBuilder<T> _alterations
list, which fires AFTER applyPolicies + applyPostPolicies during
DocumentMapping construction, so blanket ForAllDocuments policies can't
override them.

Updated the reproducer from JasperFx#2566 to assert the new guarantee: Envelope
is NOT tenant-partitioned after the async-projection store runs, and the
subsequent inline-side-effects store does not throw
MartenSchemaException on its first SaveChanges.

Verification:
- Bug_4268 reproducer: 1/1 pass (was failing pre-fix)
- MartenTests subset (Bugs + MartenOutbox + publish_messages + AncillaryStores): 52/52 pass
- Wolverine CoreTests: 1346/1346 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants