feat: add projection rebuild command for ProjectionV2#646
Merged
Conversation
…ventStoreStreamingChannelAdapterBuilder
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.
Why is this change proposed?
ProjectionV2 supports
backfillfor catching up on historical events, but lacks a way to fully rebuild a projection from scratch — resetting its tracking state and re-processing all events. This is essential for recovering from corrupted projection state, applying schema changes, or fixing bugs in projection logic without registering another version of the projection. It's especially useful for partitioned projections that can be rebuilt in the background without long running blocking transaction (as it rebuilds one aggregate at a time).Description of Changes
#[ProjectionRebuild]class attribute to configure rebuild behavior (partition batch size, async channel)#[ProjectionReset]lifecycle method support — called per-partition during rebuild with partition context headers (aggregate ID, type, stream name)ecotone:projection:rebuildconsole command that triggers rebuild viaProjectingManager::prepareRebuild()RebuildExecutorHandlerthat iterates partitions and executes reset + re-process per partition within a transactionProjectorExecutorinterface withreset()method implemented across all executorsUsage
Trigger via console:
ecotone:projection:rebuild --name=ticket_listUse case scenarios
sequenceDiagram participant Console as ecotone:projection:rebuild participant Manager as ProjectingManager participant Executor as RebuildExecutorHandler participant Projection as ProjectorExecutor Console->>Manager: prepareRebuild() Manager->>Manager: Batch partitions loop Each batch (sync or async) Manager->>Executor: executeRebuildBatch() loop Each partition Executor->>Projection: reset(partitionKey) Note over Projection: Calls #[ProjectionReset] with<br/>partition context headers Executor->>Projection: Re-process all events end endPull Request Contribution Terms