Repository navigation
Throw StreamLockedException from a batched FetchForExclusiveWriting on a locked stream - #5818
Merged
jeremydmiller merged 3 commits intoNov 5, 2026
Conversation
…stream The non-batched FetchForExclusiveWriting reports a stream another session holds locked as StreamLockedException. The batched form fails with the timed-out batch's MartenCommandException instead, or with a bare NpgsqlException when the exclusive fetch is not the batch's first item. A slow query elsewhere in the batch has to keep failing as a MartenCommandException.
…n a locked stream The non-batched FetchForExclusiveWriting turns a read timeout (or 25P02) on the stream's `for update` into StreamLockedException, but the batched form surfaced the raw MartenCommandException, or a bare NpgsqlException when the exclusive fetch was not the batch's first item. A Wolverine handler using [WriteAggregate(LoadStyle = ConcurrencyStyle.Exclusive)] loads through the batch, so error handling keyed on StreamLockedException never matched. BatchedQuery.Execute now applies the same translation, but only when the failure happens while the reader advances into an exclusive fetch's results, where its `for update` is the first statement. A slow query elsewhere in the batch still fails as before.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
esond
commented
Nov 5, 2026
This was referenced Nov 6, 2026
Closed
This was referenced Nov 13, 2026
This was referenced Nov 15, 2026
This was referenced Nov 20, 2026
Open
This was referenced Nov 27, 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.
Fixes #5817.
A batched
FetchForExclusiveWritingon a locked stream now throwsStreamLockedException, like the direct call does. Before, it threwMartenCommandException, orNpgsqlExceptionwhen it wasn't the batch's first item.Start with
BatchedQuery.Execute. It translates a read timeout or 25P02 only while the reader moves into an exclusive fetch's results, because thefor updateis that item's first statement. The four fetch-plan handlers just report their stream id through a new internalIExclusiveFetchHandler.MartenCommandException, and a test covers it.SessionTransactionUnusableExceptionpass through unchanged.FetchForWritingandbatched_queryingtests also pass.