Sorry to resurrect an old topic, but I am having the exact same conundrum.

My particular use case is:
- I have a persistent actor that is similar to a FSM  with a "state" enum 
that represents its current state
- Some additional business logic has lead to me wanting to inspect the 
previous states the actor has gone through to get to the current state - so 
I now want to keep a list of historical states in that actor  
- This seems perfect for the Event sourcing model, I have all the 
historical events so I can recreate the historical states in recovery
- But - snapshots get in the way of this! - to recover the historical 
states from a snapshot I need to persist them to my snapshot, but old 
snapshots won't have this which will then break my business logic

So it seems like it would be a valuable feature to reject all snapshots 
that have no historical states within them, and if no snapshots match this 
then replay all events from the journal.

Using SnapshotSelectionCriteria.None would disable snapshots forever, using 
a timestamp seems problematic as it would be dependent on when the new code 
is deployed, and selectively deleting them also seems hard.

Is there no easy way to do this? Or maybe this technique is flawed...?

Cheers,
Stephen

On Thursday, 29 December 2016 11:38:38 UTC, Konrad Malawski wrote:
>
> There is no way to "reject but try a different snapshot".
> The offered snapshot is the latest one matching the criterium, and you 
> either use it or not - "ignoring it".
>
> There's no "yeah not that one but another one". How would the lib know 
> what you're looking for? 
> Keep offering all snapshots you possibly had? Sounds rather weird.
>
> -- 
> Konrad `ktoso` Malawski
> Akka <http://akka.io> @ Lightbend <http://lightbend.com>
>
> On 29 December 2016 at 12:36:07, Sergey A. (sergey....@gmail.com 
> <javascript:>) wrote:
>
> Hi All,
>
> May be I'm missing something obvious (sorry about that - in between 
> holydays week). 
>
> So my problem is - persistent state of persistent actor is changed 
> (evolved), so I want to recover from events if previous snapshot was taken 
> from old state.
>
> Documentation says:
>
> http://doc.akka.io/docs/akka/2.4/scala/persistence.html
>
> To skip loading snapshots and replay all events you can use 
>> SnapshotSelectionCriteria.None. This can be useful if snapshot 
>> serialization format has changed in an incompatible way. It should 
>> typically not be used when events have been deleted.
>>
>>
>>    1. override def recovery = 
>>    2. Recovery(fromSnapshot = SnapshotSelectionCriteria.None) 
>>
>> At first look, it's exactly what I need, but in this case I should:
>
> 1. start application with SnapshotSelectionCriteria.None and run until 
> new snapshot taken
> 2. change code or configuration (to remove override)
> 3. start application again and forever (until next upgrade)
>
> if I did not perform steps 2.-3. and application will be restarted app 
> will be recovered from events (soo slow). 
>
> So I'm looking for something like that:
>
> Введите код...  override def receiveRecover: Receive = {
>     case cmd@SnapshotOffer(metadata, offeredSnapshot: OldFormat) => 
> rejectOffer
>     case cmd@SnapshotOffer(metadata, offeredSnapshot: NewFormat) => state 
> = offeredSnapshot
>
>
> Btw, I already tried to ignore SnapshotOffer with old type (removing 1st 
> case above), but it led to worst variant - snapshot was silently bypassed 
> and only recent events (not included into spanshot) replayed.
>
> Any thoughts ?
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: 
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+...@googlegroups.com <javascript:>.
> To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to