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
Handle truncated streams when reading events for projections #2956
Handle truncated streams when reading events for projections #2956
Conversation
Any chance we could get this approved to run on the CI process? |
Thank you for the PR @StuartFergusonVme! When a stream has been truncated, the storage reader should return an empty response with NextEventNumber set to the event number of the next available event to read from and IsEndOfStream set to false. It is then up to the client to issue another read from there. It looks like the projections aren't making use of the IsEndOfStream property of the read, and simply stopping when there are no events. |
…handler' into task/#2954_streamstuckat-1
StreamEventReader, TransactionFileEventReader to handle EOF correctly as requested
@hayley-jean updated as requested. I have added the changes in from #2947 with this as well as without these changes the Access Violation error is hit that has been fixes with that PR. |
Could someone approve this so the workflow can kick off? |
@StuartFergusonVme Thanks for updating! However when I test this locally I see that this change is actually more involved than I initially thought The projection readers assume that EOF means that there are no events, so don't process events or continue reading once it sets EOF to true - resulting in the projection still getting stuck. For example, the StreamEventReader only publishes the events to the projections if it's not EOF, and the other readers appear to have similar issues. |
@hayley-jean - does that mean we need to check message.events.length So we would do:
|
I think that could work @StevenBlair123, it would be the closest to what the readers seem to expect at the moment |
OK, we will plug that in just now. |
@hayley-jean pushed up some more updates as requested, can you approve the CI process please? |
@hayley-jean just noticed from the last run that the test "EventStore.Core.Tests.ClientAPI.when_connection_drops_messages_that_have_run_out_of_retries_are_not_retried" failed only on ubuntu-18.04 with the error Is this just a timing issue when running the tests as I can't see how the code changes I have made can affect this especially as it is passing on windows? |
@StuartFergusonVme Thanks! The changes you've made fixes the issue for stream, event type and $all projections 😄 The tests aren't failing because of this PR - they've been rather flaky recently. If this PR breaks anything it would only be in Projections.Core.Tests The only one left that doesn't work is multi-stream projections, for example:
There's probably something preventing the read from moving on in the case when no events are returned, if you want to have a look at that in the MultiEventReader. |
@hayley-jean - we had actually tested this specifically on multi streams (one of the streams was the root of the problem) and it looked like this code was working. |
@StevenBlair123 Sure, the test I ran was:
How many truncated events did you test with? As for fixing it, it looks like the positions that are used in the reads are only updated when events are delivered (see here). |
@hayley-jean - thanks. we will have a look at this tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This all works on my side now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! It looks good to me too. Could you get rid of unnecessary changes and squash your commit too?
…tail/EventStore into task/#2954_streamstuckat-1
@YoEight I think I have done what you have asked for but the CI process is blocked now, would you be able to approve the workflow and confirm the change I have done is as you requested. |
Could we get someone to accept workflow for CI? |
@StuartFergusonVme I expected you squashed your commits too 😄 You back merged on your PR branch, let me see what I can do, otherwise, I might have to create another PR to merge this. |
@StuartFergusonVme @StevenBlair123 I didn't manage to fix your PR so I opened a new one here: #2979 |
Fixed: Fix projections getting stuck when reading from truncated streams
Fixes #2954