Skip to content

Adding rebuild projection bug on MultiStreamProjections with Services.#3898

Merged
jeremydmiller merged 2 commits intoJasperFx:masterfrom
Novil-Inc:master
Aug 8, 2025
Merged

Adding rebuild projection bug on MultiStreamProjections with Services.#3898
jeremydmiller merged 2 commits intoJasperFx:masterfrom
Novil-Inc:master

Conversation

@micahosborne
Copy link
Contributor

Getting the following error when trying to rebuild a projection that has been add via AddProjectionWithServices, and a MultiStreamProjection.

To Reproduce run the "use_multistream_projection_as_scoped_and_inline_on_martenStore" test.

         at Marten.Internal.Sessions.ProjectionStorage`2.StoreProjection(TDoc aggregate, IEvent lastEvent, AggregationScope scope) in /_/src/Marten/Internal/Sessions/DocumentSessionBase.ProjectionStorage.cs:line 114
         at JasperFx.Events.Daemon.AggregationRunner`4.ApplyChangesAsync(ShardExecutionMode mode, IProjectionBatch batch, TOperations operations, EventSlice`2 slice, IProjectionStorage`2 storage, IAggregateCache`2 cache, CancellationToken cancellation)
         at JasperFx.Events.Daemon.AggregationRunner`4.<>c__DisplayClass14_0.<<BuildBatchAsync>b__0>d.MoveNext() in /_/src/JasperFx.Events/Daemon/AggregationRunner.cs:line 56
      --- End of stack trace from previous location ---
         at JasperFx.Events.Daemon.AggregationRunner`4.BuildBatchAsync(EventRange range, ShardExecutionMode mode, CancellationToken cancellation) in /_/src/JasperFx.Events/Daemon/AggregationRunner.cs:line 99
         at JasperFx.Events.Daemon.GroupedProjectionExecution.buildBatchAsync(EventRange range, CancellationToken cancellationToken) in /_/src/JasperFx.Events/Daemon/GroupedProjectionExecution.cs:line 219
fail: Marten.Events.Daemon.ProjectionDaemon[0]
      Error trying to build and apply changes to event subscription Location:All from 1500 to 2000
      System.NotSupportedException: Specified method is not supported.
         at Marten.Generated.DocumentStorage.LightweightLocationDocumentStorage705746301.Overwrite(Location document, IMartenSession session, String tenant) in /home/micah/novil-next/src/WebApp/Novil.Web/Internal/Generated/DocumentStorage/LocationProvider705746301.cs:line 562
         at Marten.Internal.Sessions.ProjectionStorage`2.StoreProjection(TDoc aggregate, IEvent lastEvent, AggregationScope scope) in /_/src/Marten/Internal/Sessions/DocumentSessionBase.ProjectionStorage.cs:line 114
         at JasperFx.Events.Daemon.AggregationRunner`4.ApplyChangesAsync(ShardExecutionMode mode, IProjectionBatch batch, TOperations operations, EventSlice`2 slice, IProjectionStorage`2 storage, IAggregateCache`2 cache, CancellationToken cancellation)
         at JasperFx.Events.Daemon.AggregationRunner`4.<>c__DisplayClass14_0.<<BuildBatchAsync>b__0>d.MoveNext() in /_/src/JasperFx.Events/Daemon/AggregationRunner.cs:line 56
      --- End of stack trace from previous location ---
         at JasperFx.Events.Daemon.AggregationRunner`4.BuildBatchAsync(EventRange range, ShardExecutionMode mode, CancellationToken cancellation) in /_/src/JasperFx.Events/Daemon/AggregationRunner.cs:line 99
         at JasperFx.Events.Daemon.GroupedProjectionExecution.buildBatchAsync(EventRange range, CancellationToken cancellationToken) in /_/src/JasperFx.Events/Daemon/GroupedProjectionExecution.cs:line 219
         at JasperFx.Events.Daemon.GroupedProjectionExecution.buildBatchAsync(EventRange range, CancellationToken cancellationToken) in /_/src/JasperFx.Events/Daemon/GroupedPro
Finished rebuilding Location in 569 ms```

@micahosborne
Copy link
Contributor Author

It actually happens on the single stream projection too when trying to rebuild after.

@micahosborne
Copy link
Contributor Author

micahosborne commented Aug 7, 2025

I am able to get it running using the below change to AggregateRunner.cs (line: 173). Assuming im not missing some other detail.

     case ActionType.Store:
                cache.Store(slice.Id, snapshot!);
                storage.Store(snapshot!); // <-- this should be used
                storage.StoreProjection(snapshot!, lastEvent, Projection.Scope); <-- this should not be used.
                break;

@jeremydmiller jeremydmiller merged commit 8438447 into JasperFx:master Aug 8, 2025
1 of 3 checks passed
@jeremydmiller
Copy link
Member

Your test is a single stream projection, but I think the issue is systematic for all aggregate projections anyway

@micahosborne
Copy link
Contributor Author

Oh sorry about that. Must have forgot to switch the base class.. But yes seems to be both. Thanks for taking a look!

@jeremydmiller
Copy link
Member

The fix is coming up later today w/ changes in JasperFx.Events

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