Repository navigation
GH-684 Composite projections: opt-in KeepUnchangedMembers keeps unchanged members' documents and progress across a version bump - #1290
Merged
Conversation
…s that did not change keep their documents and progress Each member already runs under its own progression row, named for its own version. With KeepUnchangedMembers on (single-stage composites only), a member whose row is ahead of the composite's position skips the replay up to it, and MembersToTearDownAsync tells a store's rebuild teardown to leave such members standing. Off by default: no row is read and every member replays, as before. Strictly additive: a new property, a new ExecutionStage overload, a new async method, and a gated compliance suite with a default-throwing builder member. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of #684: the JasperFx side. The design is in #684 (comment). The store halves are marten#5247, polecat#490 and fisher#109, so #684 stays open until they land.
What it does
A composite's members already have their own identity:
ProjectionStage.MemberShardNamenames each onemember:V{member.Version}, and each writes its own progression row in the composite's batch. This PR makes those rows count.CompositeProjection.KeepUnchangedMembers(opt-in, defaultfalse). Turn it on, then bump both the member you changed and the composite. The composite replays from 0. Before its first range, the composite execution reads each member's own row. A member whose row is ahead of the composite's floor is kept through that position: ranges at or below it do nothing for that member (no apply, no progress write), and a straddling range hands it only the later events, with its floor at its own row, so a store's "update where at floor" progress write matches. Members that changed have no row for their new version, so they replay in the same pass. Once past the window, every member is in lockstep again.CompositeProjection.MembersToTearDownAsync(IEventDatabase, ShardName? parent, CancellationToken): the members a store's rebuild teardown should tear down. That's all of them unless the flag applies, in which case a member whose row is ahead of the composite's own row is left out. So a rebuild after a bump keeps the unchanged members, while a rebuild with no bump (everything in lockstep, i.e. a repair) still tears down and rebuilds every member.Binary compatibility
Strictly additive:
CompositeProjection, and a new public async method;ExecutionStage.ExecuteDownstreamAsync(EventRange, IReadOnlyDictionary<ISubscriptionExecution,long>?)as a new overload; the existing one-argument method now forwards to it;internal initproperty onCompositeExecution;JasperFx.Events.ComplianceTests, a default-throwingIComplianceCompositeBuilder.KeepUnchangedMembers()and aSupportsKeepingUnchangedCompositeMembersfixture flag that defaults tofalse.No signature changed. With the flag off, the execution reads no extra progression rows and every member processes every range exactly as before.
Tests
EventTests/.../CompositeKeepUnchangedMembersTests(10 tests), using a progression table that mirrors Marten's insert-at-0 / update-at-floor rule:JasperFx.Events.ComplianceTests: a newCompositeKeepUnchangedMembersCompliancesuite, marked[RequiresCapability("SupportsKeepingUnchangedCompositeMembers")], so a store that hasn't adopted this is excused from the enrollment check automatically. It's the store-side proof: after a simulated bump (the composite's own row deleted), a rebuild leaves the kept members' documents untouched, and a rebuild with no bump still rebuilds every member. Each store enrolls it when it implements teardown throughMembersToTearDownAsync.What each store changes
As in the design comment:
MembersToTearDownAsync, and keep a kept member's documents and progression row.KeepUnchangedMembers()on the compliance builder and flip the fixture flag.Gate
The full local gate (
stoat gate exec critter-stack-net11-rc/gate-slot-jasperfx -- ./build.sh Test) is green on this commit. It ran after the #1287 gate, never at the same time.🤖 Generated with Claude Code