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

StreamEventReader Fix (no InvalidOperationException) #1774

Merged
merged 4 commits into from Dec 18, 2018

Conversation

3 participants
@riccardone
Copy link
Member

riccardone commented Nov 21, 2018

Fix scenario when $maxAge/$MaxCount are set on the original stream and events are written while the projection is stopped.
To manually reproduce:

  1. stop the projection
  2. write events on the original stream
  3. start the projection
  4. write other events on the original stream
    5 (original code) the projection goes in Fault state + thrown an InvalidOperationException
    5 (with this fix) the projection keep working and log the error

Fixes #1468

This PR introduce a new option: FaultOutOfOrderProjections (default true)
FaultOutOfOrderProjections=true: the projection that process an event with a not expected number will go in Fault state and a reset is required
FaultOutOfOrderProjections=false: the projection that process an event with a not expected number will keep going working and the error * will be logged

*Event number {0} was expected in the stream {1}, but event number {2} was received. This may happen if events have been deleted from the beginning of your stream, please reset your projection.

@Lougarou Lougarou referenced this pull request Nov 22, 2018

Open

StreamEventReader Fix #1773

riccardone added a commit that referenced this pull request Nov 23, 2018

Fixes StreamEventReader bug: when a stream with deleted events($MaxAg…
…e/$MaxCount) Fault the projection instead of thrown an InvalidOperationException

CherryPicked from #1774 PR

@riccardone riccardone requested a review from Lougarou Nov 26, 2018

@riccardone riccardone removed the request for review from Lougarou Dec 5, 2018

@jen20
Copy link
Member

jen20 left a comment

This looks ok for 5.0.0, but it's a breaking change to sequencing so probably should not be back ported. Can you squash the commits and explain the issue in the unified commit message, then LGTM

Fixes StreamEventReader bug: when a stream with deleted events($MaxAg…
…e/$MaxCount) Fault the projection instead of thrown an InvalidOperationException

Log the message "Event number {0} was expected in the stream {1}, but event number {2} was received" in case events has been written on a stream with $maxAge/$maxCount set while the projection was stopped
Fixed unit tests
Changed the expectations of 2 tests in order to accept the different sequence of events when the condition happens

fixed error reason message

@riccardone riccardone force-pushed the StreamEventReaderFix2 branch from 6556ee9 to d22da7f Dec 7, 2018

@jageall
Copy link
Collaborator

jageall left a comment

I think this whole thing needs to go behind a config switch.

If people are not thinking about the impact of maxAge/maxCount on their projections they need to make an explicit choice to allow the breaking of ordering within those projections.

For those that understand what they are doing they can switch it on

I would prefer to see it rather than a config switch to be a projection option. This would help discoverability and make switching it on less of a sledgehammer

riccardone added some commits Dec 13, 2018

fix the multistream projections with the same fix to avoid the except…
…ion and log the error

new option FailOutoforderProjections to keep the current behaviour (default true)
fixed tests for multistream
added 1 new test for error message check
Show resolved Hide resolved src/EventStore.ClusterNode/ClusterNodeOptions.cs Outdated
Show resolved Hide resolved src/EventStore.Core/Util/Opts.cs Outdated

@riccardone riccardone merged commit be3f105 into master Dec 18, 2018

@riccardone riccardone deleted the StreamEventReaderFix2 branch Dec 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment