Fix bug with catch-up all streams subscription where the checkpoint is not committed for hard deleted streams #238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Track in-flight events sent to subscribers to ensure that the last seen checkpoint is committed for a subscription. The acknowledgements are correlated with the events sent to the subscriber.
This pull request ensures that a catch-up subscription to all streams will correctly commit the last seen checkpoint even when a stream has been hard deleted which causes gaps in the sequence of event numbers. Previously it was assumed there would be no gaps in the event number sequence so the checkpoint could be determined as "last checkpoint + 1" (1, 2, 3, 4, etc.). However this is not the case when a stream has been hard deleted since its events will also be removed leaving gaps in the "all stream" event number sequence (e.g. 1, 2, 9, 10, 15, 16).
Without this change a catch-up subscription to a stream containing events from another stream that has been hard deleted will not persist the last seen checkpoint once it reaches the position of a hard deleted event. Therefore whenever the subscription restarts it will replay all events from the checkpoint, this will be the position of the first hard deleted event.