GH-4511: throw SagaConcurrencyException from the Sqlite lightweight saga storage - #4533
Merged
Merged
Conversation
…aga storage The Sqlite saga schema threw a bare System.Exception when an optimistic-concurrency update touched zero rows. Every other lightweight provider (Postgres, SQL Server, MySQL, Oracle) and every document-store saga path throws SagaConcurrencyException at the same point, which derives from JasperFx.ConcurrencyException precisely so a single OnException<ConcurrencyException>() policy covers saga concurrency on all of them. Wolverine's failure-rule matching is `ex is T`, so the bare Exception fell through that policy to the default MoveToErrorQueue continuation: same saga, same code, a different outcome depending on which persistence package is referenced. Fisher-backed hosts inherit this, since Wolverine.Fisher composes over the Sqlite persistence. The existing Sqlite test asserted Should.ThrowAsync<Exception>, which matches anything at all, so it passed over the defect. It now asserts the type, its ConcurrencyException ancestry, and the message shape the other providers use. Verified as a negative control: that test fails against the old bare throw. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VDUrBeB4tTnKj4AExCS1nj
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.
Closes #4511.
The Sqlite lightweight saga storage threw a bare
System.Exceptionwhen an optimistic-concurrency update touched zero rows:Every other lightweight provider throws
SagaConcurrencyExceptionat that point — Postgres, SQL Server, MySQL, Oracle — as do the EF Core, CosmosDB, S3, Azure Blob and Redis saga paths.SagaConcurrencyExceptionderives fromJasperFx.ConcurrencyException(GH-3444) so that oneOnException<ConcurrencyException>().RetryWithCooldown(...)policy covers saga concurrency failures on every provider.Wolverine's failure-rule matching is
ex is T, so on Sqlite the bareExceptionfell straight through that policy to the defaultMoveToErrorQueuecontinuation. Same saga, same handler code, a different outcome depending on which persistence package is referenced. Fisher-backed hosts inherit it, sinceWolverine.Fishercomposes over the Sqlite persistence.Change
src/Persistence/Wolverine.Sqlite/Sagas/DatabaseSagaSchema.csnow throwsSagaConcurrencyExceptionwith the same message shape as the other providers, so the wording is uniform too.Why this was invisible
SqliteTests/Sagas/saga_storage_operations.csalready had aconcurrency_exception_when_version_does_not_matchtest — assertingShould.ThrowAsync<Exception>(), which matches anything that throws at all. It passed over the defect for as long as it has existed. It now asserts the exception type, itsConcurrencyExceptionancestry (the property the retry policy actually depends on), and the message shape.Verified as a negative control: with the production change stashed, that test fails (1 of 6); with it applied, all 6 pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VDUrBeB4tTnKj4AExCS1nj