Skip to content

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

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

if (snapshotIsOptional)
{
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
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