Skip to content
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

Allow snapshots to be optional when recovering a persistent actor #7382

Open
chrisjhoare opened this issue Nov 7, 2024 · 2 comments
Open
Labels
akka-persistence DX Developer experience issues - papercuts, footguns, and other non-bug problems.

Comments

@chrisjhoare
Copy link
Contributor

Is your feature request related to a problem? Please describe.
If snapshot loading fails (for example due to serialization changes) the current behavior is to stop the actor.

case LoadSnapshotFailed failed:
timeoutCancelable.Cancel();
try
{
OnRecoveryFailure(failed.Cause);
}
finally
{
Context.Stop(Self);
}

I have an actor that derives its state from queries to a 3rd party API. Persistence snapshots help improve the start up time by skipping some of the queries needed, but in the case of a failing snapshot I would much prefer the start up took a bit longer than the actor couldn't start at all.

I could also see this being useful for event sourcing, where you'd prefer to fall back to just reading all events if snapshots could not be retrieved.

Describe the solution you'd like
Akka on the JVM already has this feature so it can be ported directly. It would be opt in configuration for the snapshot storage
https://doc.akka.io/libraries/akka-core/current//typed/persistence-snapshot.html#optional-snapshots

Describe alternatives you've considered
One thing I did consider is if this something you would want to configure at the actor level rather than per-snapshot store. For example you could make it a setting on the Recovery class which is already responsible for controlling which snapshots are retrieved for a particular actor. This would however be a departure from the JVM implementation.

Additional context
I've ported the JVM implementation as close as I can here chrisjhoare@1d66bcc

Would be happy to raise this as a PR if this is a solution you'd accept!

@Aaronontheweb Aaronontheweb added akka-persistence DX Developer experience issues - papercuts, footguns, and other non-bug problems. labels Nov 7, 2024
@to11mtm
Copy link
Member

to11mtm commented Nov 27, 2024

I've ported the JVM implementation as close as I can here chrisjhoare@1d66bcc

Would be happy to raise this as a PR if this is a solution you'd accept!

Was this ported from Akka or Pekko? And if it was from Akka, What commit?

We have to be -very- careful about making sure we do not take code that may have been derived from 'Modern' JVM Akka.

That said it's not a bad idea at all.

@chrisjhoare
Copy link
Contributor Author

I ported from Akka. This is the commit where it was added akka/akka@e09de4f

Apologies, I hadn't thought about the change to the Akka licence (Presume that would be the issue?). I think this this is ok though looking at the date. Might be worth adding a small clarification here about porting JVM features (https://getakka.net/community/contributing/index.html#port-a-missing-feature-or-add-a-new-one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-persistence DX Developer experience issues - papercuts, footguns, and other non-bug problems.
Projects
None yet
Development

No branches or pull requests

3 participants