-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
OptimisticConcurrencyException is not handled properly in EntityFrameworkReadModelStore #1028
Comments
I'm personally not an EF expert. But wouldn't these line update the value? EventFlow/Source/EventFlow.EntityFramework/ReadStores/EntityFrameworkReadModelStore.cs Lines 253 to 255 in b277c52
|
You could also try providing a custom implementation for this class https://github.com/eventflow/EventFlow/blob/b277c52ea409c52e5f5b78f9cedfd0b3d399015d/Source/EventFlow/Core/RetryStrategies/OptimisticConcurrencyRetryStrategy.cs that adds some metrics to get some insights into the amount of times its happening. For a high load system it might simply be because the retry limit is reached. |
Summary:
I faced the Optimisic Concurrency exception. After skimming through the code, I think that this only happens with
EntityFrameworkReadModelStore
. I will tell you my understanding and I seek for input from you who are more familiar with the source code.Description:
I cannot consistently reproduce the issue but it typically happens when multiple commands for the same aggregate ID are published within a short period of time.
Optimistic concurrency exceptions during read model updates might not be handled as expected, potentially leading to data inconsistency (i.e. events saved but not applied to read model).
It appears that reloading the read model from the database upon encountering an optimistic concurrency exception during read model updates might not be happening. This is due to the reuse of the same
DbContext
instance across retries during read model updates (see this code inEntityFrameworkReadModelStore
). Shouldn't there be aDbEntityEntry.Reload()
call somewhere to force readmodel reload?Stacktrace
The text was updated successfully, but these errors were encountered: