EntityFrameworkCore optimistic concurrency support for saga#1707
Merged
jeremydmiller merged 1 commit intoJasperFx:mainfrom Oct 13, 2025
Merged
EntityFrameworkCore optimistic concurrency support for saga#1707jeremydmiller merged 1 commit intoJasperFx:mainfrom
jeremydmiller merged 1 commit intoJasperFx:mainfrom
Conversation
JMounier
commented
Sep 18, 2025
| writer.WriteComment("Only intercepts concurrency error on the saga itself"); | ||
|
|
||
| writer.WriteLine($"BLOCK:if (error.Entries.Any(e => e.Entity == ${_saga.Usage})"); | ||
| writer.WriteLine($"throw new SagaConcurrencyException($\"Saga of type {_saga.VariableType.FullNameInCode()} and id {{ {SagaChain.SagaIdVariableName} }} cannot be updated because of optimistic concurrency violations\");"); |
Contributor
Author
There was a problem hiding this comment.
Using SagaChain.SagaIdVariableName seems like an oversight but I don't have access to the "Variable sagaId" from neither CommitUnitOfWorkFrame nor DetermineUpdateFrame.
dbc0164 to
1d60f9b
Compare
Member
|
@JMounier Hey, I did the trick of pulling in the PR, then running the tests. Next time your shop tries a pull request, just make sure to run the test suite locally please? It's 95% there, but the codegen was off. |
This was referenced Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds support for optimistic concurrency when a saga is persisted using the EFCore integration (implementation based on concurrency token cf. Handling Concurrency Conflicts). It patches the code generation to:
SagaConcurrencyExceptionwhenSaveChangesAsyncthrows aDbUpdateConcurrencyExceptionimpacting the actual saga entity.Versionproperty as a concurrency token.P.S. I tried running the
./build.shto test my change but I have the wholeHttpTestssuite failing for unclear reasons andCodegenPreviewCommandfailing to compile with the following error: