Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Add restart on failure option for event sourced entities #439

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

pvlugter
Copy link
Member

For #375. This adds support for restarting entities on user failures, for the case of emitted events before fail is called, while allowing events to be applied immediately to have updated state.

Use actor restart to retain the mailbox. The stream relay functionality is moved to a separate actor, so that it can be a stable relay actor ref for the entity when reconnecting the stream. The entity actor still has its own custom command stash. We could use standard actor stash (and persistent actors use a separate stash internally) but because there are only stash and unstashAll public methods, with several commands queued it would mean un-stashing all of them and then re-stashing messages again, for each command processed. We would also lose the instrumentation for the command stash that we have now. So instead use the (akka private) prepending to the mailbox that actor stash uses, but only unstash back to the mailbox on restarts. Prepending means that we always retain command order, even if there are recently arrived messages in the mailbox.

Update java-support to apply emitted events immediately, reverting back to the earlier behaviour, and use the entity restart option on failures if events have been emitted. Update the TCK model test for event sourced, now that state is updated in responses again. For the emit-then-fail test in the TCK, it currently always expects the restart option to be used. If language supports optimise this by keeping local snapshots, or have a different approach to atomicity, then this test will need to be updated to test either approach. We can wait until we get to that point though.

@pvlugter
Copy link
Member Author

Note: the CircleCI tests will fail at the moment. There's an issue with payment and so the large machine is not allocated. We'll just need to ignore those tests for now.

@jroper jroper merged commit c68aba7 into cloudstateio:master Sep 29, 2020
@pvlugter pvlugter deleted the entity-restart branch October 1, 2020 21:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants