Fix soft delete's "truncate before" checkpoint. #1736
Closed
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.
It seems that the truncate before (
$tb
) event is incorrectly written into the stream every time a soft delete occurs. The documentation explicitly states the following:Source: https://eventstore.org/docs/server/deleting-streams-and-events/index.html?q=delete%20stream
As you can verify in my PR, this is not the case.
I've already described the issue here:
https://stackoverflow.com/questions/52605285/event-store-cannot-write-to-soft-deleted-streams
and here:
https://groups.google.com/forum/#!topic/event-store/DRtYcK74oRE
To summarize:
$tb
checkpoint value instead of the last event number.Please carefully review this PR because it seems strange that no one reported this issue before. I've manually emitted
$tb
events to my local event store using the client API and was able to get the behavior described in the docs. For this to work I needed to set the checkpoint value to the number of events in the stream. I am not 100% confident thatexpectedVersion + 1
(my change) is equivalent to the number of events in the stream. Would be great if someone can confirm or suggest a better fix.