-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Same Event Applied Twice when Generating Aggregate Snapshot #1408
Comments
Hi Paul, thanks for the elaborate report. Since you mentioned the BatchingUnitOfWork and the DefaultUnitOfWork, am I correct in assuming you're using an in-process snapshotter? In other words, you did not configure an ExecutorService on the snapshotter? |
Hi Allard, thanks for the prompt response. You're correct, we haven't specified an ExecutorService for the snapshotter. We're using the |
Hi Paul, I'm unable to reproduce the problem on the master branch. Looking at the code, it seems that Axon already takes into account that some of the events in the "staged events" may overlap with what's returning from the Event Store, as these events may, or may not have been stored there yet. Which version of Axon are you seeing this behavior on? |
Hi, we're currently using version 4.3. I think the problem we're seeing isn't due to an overlap between "staged events" and the contents of the event store, it's an overlap between the "staged events" held by units of work with a parent->child relationship. In our case the parent |
Events are staged in a Unit of Work when they are published. However, when a Unit of Work is nested, committing a UoW, will stage the events in a parent UoW. When reading staged events during a commit, it is possible that staged events have already been promoted to the parent UoW and are then being read, causing duplicates. This commit prevents the occurrence of duplicates when reading staged events from a Unit of Work. Resolved issue #1408
Thanks for the clarification. I managed to find the culprit and resolved it in #1416 |
Great! Thanks Allard. |
Closing this issue as it has been resolved in pull request #1416. |
Hi,
I'm currently experiencing some unexpected behaviour related to aggregate snapshotting and I suspect it may be due to a bug.
I'm using the
EventCountSnapshotTriggerDefinition
to control when aggregate snapshots are created. This is working fine and snapshots are being triggered when required. However, when theAggregateSnapshotter
constructs the snapshot event it publishes the most recent event twice. For example, if the event count threshold is set to 100 then the snapshotter will publish event 99 twice. In most cases this is not an issue. However, there are some events in my current implementation for which the handling is not idempotent and this is creating aggregates with an invalid state.When I debug the snapshotting process I can see that the duplicate event is being added to the event stream when a call is made to
AbstractEventBus.queuedMessages()
This method returns a list of all events held by the current unit of work and its parents. In our case, the parentBatchingUnitOfWork
and its childDefaultUnitOfWork
both hold a reference to the same event, which leads to it being duplicated in the resultant list.Please let me know if you require any further details regarding this issue.
Thanks,
Paul
The text was updated successfully, but these errors were encountered: