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

Reorder ChangeState(ProcessingCommands()) and OnReplaySuccess() inside Eventsourced.Recovery.cs #3472

Open
ErikOlufson opened this issue May 25, 2018 · 3 comments

Comments

@ErikOlufson
Copy link

Hi guys,

I was wondering if it would be smart to change the order inside Eventsourced.Recovery.cs.

When changing the EventsourcedState and the message is RecoverySuccess it would be nice to reorder OnReplaySuccess() and ChangeState(ProcessingCommands()).

Right now:

else if (message is RecoverySuccess)
{
    var m = (RecoverySuccess)message;
    timeoutCancelable.Cancel();
    OnReplaySuccess();
    ChangeState(ProcessingCommands());
    _sequenceNr = m.HighestSequenceNr;
    LastSequenceNr = m.HighestSequenceNr;
    _internalStash.UnstashAll();
    base.AroundReceive(recoveryBehavior, RecoveryCompleted.Instance);
    ReturnRecoveryPermit();
}

Reordered:

else if (message is RecoverySuccess)
{
    var m = (RecoverySuccess)message;
    timeoutCancelable.Cancel();
    ChangeState(ProcessingCommands());
    OnReplaySuccess();
    _sequenceNr = m.HighestSequenceNr;
    LastSequenceNr = m.HighestSequenceNr;
    _internalStash.UnstashAll();
    base.AroundReceive(recoveryBehavior, RecoveryCompleted.Instance);
    ReturnRecoveryPermit();
}

If this would be done it is possible to check variables like IsRecovering inside the overriden OnReplaySuccess() and to ensure that all recoveries are done. Right now I can check IsRecovering inside my overriden OnReplaySuccess() but the status of IsRecovering is not up to date cause this status will be set inside ChangeState(ProcessingCommands()).

What do you think about this idea?

Best regards!

@ismaelhamed
Copy link
Member

Since OnReplaySuccess is invoked after the RecoverySuccess has been received, I think it is safe to assume that recovering is done at that point.

@Aaronontheweb
Copy link
Member

@ismaelhamed so this is a non-issue then?

@ismaelhamed
Copy link
Member

ismaelhamed commented Jun 28, 2018

@Aaronontheweb the way I see it: 1) if you need to have some side-effects after recovery has completed, you can use the OnReplaySuccess --there's no need to check IsRecovering; 2) unless you want to persist, in which case the proper way would be to capture the RecoveryCompleted event in ReceiveRecover --at this point IsRecovering is false. The later is specially true since #3366.

Does it make sense, @ErikOlufson?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants