Stop conjoined_multi_tenancy and its partitioning twin sharing a schema - #5087
Merged
Merged
Conversation
Both classes build their own DocumentStore on the hard-coded schema
"mixed_multi_tenants", wipe it with DeleteAllDocumentsAsync and then assert on
global counts. Neither carried a [Collection] attribute, so xunit v3 puts them in
separate collections and runs them in parallel: both insert their two User rows
before either counts, and both see 4. That is the CI failure
await session.Query<User>().CountAsync() should be 2 but was 4
hitting can_query_on_multi_tenanted_and_non_tenanted_documents in BOTH classes in
the same run -- two independent flakes do not synchronise like that; a contended
shared resource does.
Fixed from both directions:
- the two classes now share the "mixed_multi_tenancy" collection, so xunit will
not run them concurrently
- conjoined_multi_tenancy gets its own schema, mixed_multi_tenants_conjoined, so
they no longer touch the same tables at all
The schema name sits inside #region sample_tenancy-mixed-tenancy-non-tenancy-sample
in both files, and mdsnippets renders BOTH into docs/documents/multi-tenancy.md --
the second as the duplicate `-sample-1` anchor. The rename was applied to the copy
that only feeds that duplicate, so the primary sample readers see is unchanged;
the regenerated duplicate block is committed.
Note this is a latent isolation bug of the same family as #5070, exposed by v3's
parallelism rather than caused by it.
Verified: DocumentDbTests net10.0 is 1089/1090 with 0 failures. Worth being
straight about the limits of that -- the suite also passed on clean master, so a
green local run does not by itself prove the fix. The justification is the
mechanism (shared literal schema + separate collections + wipe-then-count), and
CI is where it gets exercised for real. mdsnippets gate, markdownlint and cspell
all clean.
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.
Fixes the CI failure that blocked #5085 from merging. Not caused by that PR — it is a latent isolation bug of the same family as #5070, exposed by xunit v3's parallelism rather than created by it.
The failure
hitting
can_query_on_multi_tenanted_and_non_tenanted_documentsin bothconjoined_multi_tenancyandconjoined_multi_tenancy_with_partitioning, in the same run. Two independent flakes don't synchronise like that; a contended shared resource does.Cause
Both classes build their own
DocumentStoreon the same hard-coded schema:then
DeleteAllDocumentsAsync(), bulk-insert twoUserrows, and assert the count is 2. Neither class carried a[Collection]attribute, so xunit v3 puts them in separate collections and runs them in parallel — both insert before either counts, and both see 4.Fix, from both directions
mixed_multi_tenancycollection, so xunit will not run them concurrently.conjoined_multi_tenancygets its own schema,mixed_multi_tenants_conjoined, so they no longer touch the same tables at all.The docs wrinkle
The schema name sits inside
#region sample_tenancy-mixed-tenancy-non-tenancy-samplein both files — and mdsnippets renders both intodocs/documents/multi-tenancy.md, the second as a duplicate-sample-1anchor. (That duplication is a pre-existing wart worth cleaning up separately: the same sample is published twice.)So the rename was applied to the copy that only feeds the duplicate anchor. The primary sample readers actually see is byte-identical; the regenerated duplicate block is committed. The
[Collection]attributes sit outside the region markers, so they don't appear in the docs at all.Verification
-sample-1anchor and not in the primary. markdownlint and cspell clean.Being straight about what the green run does and doesn't prove: the suite also passed on clean master, so a passing local run does not by itself demonstrate the fix — the collision needed CI's parallel timing to surface. The justification is the mechanism (shared literal schema + separate collections + wipe-then-count), and CI is where it gets exercised for real.
🤖 Generated with Claude Code