[axonframework] Event-Upcasting und Snaphosts: Do I have to delete all Snapshot before Upcasting?

Hi,

if you have changed the structure of an aggregate, you can choose to either build an upcaster for existing snapshots, or remove the snapshots. In the end, snapshots are just a replacement for optimization purposes. Deleting them doesn’t change the behavior of the application, other than the speed at which it will load an aggregate, the first time.

If you have just changed the structure of (some) events, you don’t need to worry about snapshots, unless that changes in the events would cause a state change in the aggregate, in which case you’re basically back into the first scenario, I described.

Hope this helps.
Cheers,

Allard

Hi,

remove the snapshots. In the end, snapshots are just a replacement for optimization purposes. Deleting them doesn’t change the behavior of the application

Is there an API for deleting snapshots of a given aggregate (couldn’t find one so far), or that needs to be taken care of via some event store level operation?
(sorry if it’s a trivial one)

Thanks,
Regards

Hi Vilmos,

Both the JDBC and JPA Event Storage Engine implementations have a deleteSnapshot function which you can use to clear out snapshots from the snapshot repository.

Both take in a ‘sequence number’ though, so the sequence number of a given Snapshot. This is in place as Axon uses that exact function right now to throw away a previous snapshot which is overridden with the new snapshot. So, this isn’t exposed on a high level, but you can use it nonetheless.

Hope this helps you out Vilmos!

Cheers,

Steven

Hi Steven,

Thanks for the answer! I realize I forgot to add I’m on Axon 4.0 with AxonServer - also an early adopter :slight_smile: - so it’s actually AxonServerEventStore/AxonIQEventStorageEngine. Those don’t appear to have anything like this, I guess this is rather a feature request then, would be nice to have such delete method there as well!
With AxonServer, what is the best way currently to remove all snapshots of an aggregate?

Thanks,
Regards

Hi Vilmos,

Great to hear you’ve moved to Axon 4 paired with Server!

Your assumption is correct though, a snapshot removal mechanism isnt’ in place yet.
This ticket describes the required work for that.

So, removing for now isn’t to simple. What you could do though, is filter out the old snapshots you’re not interested in, by setting a snapshot filter on the AxonServerEventStore.

Hope this points you in the right direction!

Cheers,

Steven

Hi Steven,

Thanks for the help! I will look into snapshot filtering then.

Regards

Hi Steven,

Is there any update on snapshot removal mechanism for Axon Server as the link to the ticket is not working?

Kind regards,

Denis

Hi Denis,

Ah, that’s because I’ve shared a private github link there… My apologies.

As far as updates go, it has not been implemented yet sadly.
What will be implemented relatively soon is a means to drop an entire file worth of snapshots.

That is, however, not the exact thing I was referring to earlier, which is dropping selected snapshots based on aggregate type/version for example.

Trusting this clarifies things for you Denis.

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
The thread also specifies where to look further for help when it comes to Axon as soon as this mailing list is closed.