-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
ReadModelPopulator is incompatible with IReadModelContext.MarkForDeletion() #845
Comments
Hello, I am not sure if I understand the problem, from what I have read you are using MarkForDeletion in your reading model. I understand that if you then want to repopulate the read model from the events, the behavior would be that when it encounters the event that triggers the MarkForDeletetion it deletes the record again. I am not sure if this is what you think or it is another problem? |
@WardenUnleashed is correct, it's the same issue. |
A pretty common scenario I have encountered has been having an event that will "delete" and another one to "restore" that comes after the delete event as a mechanism to undo that. Since there is no way to unmark the read model for deletion once |
I can only think of the logical elimination. If you wanted to do what you intend to do it would be against the way one would expect after marking a MarkOfDeletion I can't think of unmarking the record to restore it after having marked it for physical deletion. Wouldn't it be confusing? |
I don't think so. The behavior I expect would be that if Whether It doesn't seem to me like marking it for deletion needs to be a one way action and adding the capability for a read model to no longer be deleted would be super helpful. |
@Teides I don't think there should be an The way I see it, if the context is ever marked for deletion, the populator should "delete" it in memory and start over if further events would manipulate it (including a context that is not marked for deletion as the model would in reality be "new" at that point since it was recreated). Here is the code that will delete the row in SQL even if the the row would be recreated later in the "normal" one by one flow. You can see that if the model was ever marked for deletion, it gets deleted. This is regardless if later events would recreate the row. To put it another way, the core batch application assumes you would never recreate the model/row after you said you wanted it deleted. Effectively, the only reliable delete in a batch operation is a delete caused by the final event in the batch. Otherwise, your read model state will most likely be incorrect. In the It would seem to me that the read model should be recreated "new" in memory and the read model context "reset" when an event is encountered that would recreate the record after deletion. Perhaps this is functionality the I have dug into the problem off and on and the work around of soft deleting as mentioned by @WardenUnleashed is generally how we work around this issue since fixing this issue would require a change to the core EventFlow library. |
Hello there! We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. If you still require assistance with this issue, please feel free to reopen it or create a new issue. Thank you for your understanding and cooperation. Best regards, |
Hello there! This issue has been closed due to inactivity for seven days. If you believe this issue still Thank you for your contribution to this repository. Best regards, |
I have a read model which calls MarkForDeletion() when it gets into a state where it does not contain any useful information. The idea is to keep the read model table tidy and minimise storage requirements. Another benefit is that we can make certain inferences if a record is not present in the read model table.
I am attempting to use the read model populator to rebuild a read model. I have noticed that the batching functionality appears to build the read model record from all applicable events in the batch before writing the record to the database.
The problem is that after MarkForDeletion is called, another event in the batch could update the read model with meaningful information. In normal operation, the readmodel would be inserted again. However, when using the readmodelpopulator, the readmodel will simply be deleted because there is no way to 'undo' MarkForDeletion.
The only solution seems to be setting PopulateReadModelEventPageSize to 1 but this obviously degrade the performance.
The text was updated successfully, but these errors were encountered: