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

Add support for optional snapshots #7444

Merged
merged 5 commits into from
Jan 8, 2025

Conversation

chrisjhoare
Copy link
Contributor

This is the implementation for allowing persistence snapshots to be optional when failing (issue #7382)

Changes

Setting snapshot-is-optional = true in the snapshot store configuration will allow Actors to continue if there is a failure loading the snapshot (https://doc.akka.io/libraries/akka-core/current//typed/persistence-snapshot.html#optional-snapshots)

@Aaronontheweb Aaronontheweb added this to the 1.5.35 milestone Jan 7, 2025
@Aaronontheweb
Copy link
Member

Thank you very much @chrisjhoare - looks like there's just a markdown linting grumble but otherwise CI/CD seems happy. We'll review this shortly!

@Aaronontheweb Aaronontheweb self-requested a review January 8, 2025 20:36
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Enable this feature by setting `snapshot-is-optional = true` in the snapshot store configuration.

> [!WARNING]
>Don't set `snapshot-is-optional = true` if events have been deleted because that would result in wrong recovered state if snapshot load fails.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

var lpref = Sys.ActorOf(Props.Create(() => new SnapshotFailureRobustnessSpec.LoadSnapshotTestActor(Name, TestActor)));
ExpectMsg<Error>(m => m.Message.ToString().StartsWith("Error loading snapshot"));
ExpectMsg("boom-1");
ExpectMsg<RecoveryCompleted>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -61,7 +62,9 @@ private EventsourcedState RecoveryStarted(long maxReplays)
// protect against snapshot stalling forever because journal overloaded and such
var timeout = Extension.JournalConfigFor(JournalPluginId).GetTimeSpan("recovery-event-timeout", null, false);
var timeoutCancelable = Context.System.Scheduler.ScheduleTellOnceCancelable(timeout, Self, new RecoveryTick(true), Self);


var snapshotIsOptional = Extension.SnapshotStoreConfigFor(SnapshotPluginId).GetBoolean("snapshot-is-optional", false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

{
OnRecoveryFailure(failed.Cause);
Log.Info("Snapshot load error for persistenceId [{0}]. Replaying all events since snapshot-is-optional=true", PersistenceId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - might consider making this a WARNING but I think it's fine as-is for now

# recover by replaying all events.
# Don't set to true if events are deleted because that would
# result in wrong recovered state if snapshot load fails.
snapshot-is-optional = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) January 8, 2025 20:38
@Aaronontheweb Aaronontheweb merged commit 468546c into akkadotnet:dev Jan 8, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants