Repository navigation
Pin that removing a tenant from its shard takes its natural key rows - #5770
Merged
jeremydmiller merged 1 commit intoOct 26, 2026
Merged
Conversation
JasperFx#5746 (JasperFx#5742) made ShardedTenancy.RemoveTenantAsync delete a tenant's mt_natural_key_* rows before it drops the tenant's partitions, alongside the two single-database removal paths, and noted that the sharded path had no test of its own. This adds one: two tenants with a [NaturalKey] stream on one shard, then RemoveTenantFromShardAsync. The removed tenant's natural key rows go, and the other tenant's row and lookup survive. It fails on 3e77b1d, master just before JasperFx#5746 merged, with 23503: removing partition "mt_streams_rmnk_alpha" violates foreign key constraint "mt_natural_key_shardedremovalcase_stream_id_tenant_id_fkey", and passes on master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 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.
#5746 (#5742) made
ShardedTenancy.RemoveTenantAsyncdelete a tenant'smt_natural_key_*rows before it drops the tenant's partitions, along with the two single-database removal paths. It noted that the sharded path had no test of its own because "the sharded fixtures do not build partitioned events". They do:ShardedPartitionedContext.BuildShardedStoresetsUseTenantPartitionedEvents, and #5720'sremoving_a_tagged_tenant_from_its_shardruns on it.New file:
TenantPartitionedEventsTests/Sharded/removing_a_tenant_with_natural_keys_from_its_shard.cs. Two tenants with a[NaturalKey]stream share one shard, andRemoveTenantFromShardAsyncremoves one of them. The removed tenant's natural-key rows go; the other tenant's row, and itsFetchLatestby natural key, survive. No production code changes.Red on
3e77b1dfc(master just before #5746 merged):23503: removing partition "mt_streams_rmnk_alpha" violates foreign key constraint "mt_natural_key_shardedremovalcase_stream_id_tenant_id_fkey". Green on master1d65a1a2d.TenantPartitionedEventsTests: 287 passed, 2 skipped, 0 failed (net10.0, PostgreSQL 17).🤖 Generated with Claude Code