Skip to content

GH-1172 StreamLockedException carries every stream that lost the lock (StreamIds) - #1176

Merged
jeremydmiller merged 1 commit into
mainfrom
gh-1172-stream-locked-stream-ids
Nov 10, 2026
Merged

jeremydmiller merged 1 commit into
mainfrom
gh-1172-stream-locked-stream-ids

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #1172

Additive surface on JasperFx.Events.StreamLockedException, so Fisher can delete Fisher.Exceptions.StreamLockedException and throw the shared type directly from FisherSession (the #1133 ruling: a shared exception is one JasperFx.Events type, and a store's extra state moves up first). Fisher's extra state is the list of streams: SQLite takes one writer per file, so every stream in a unit of work loses the lock together.

New public surface

public class StreamLockedException : ConcurrencyException
{
    // new: StreamId and Id carry streamIds[0]; an empty list is refused with ArgumentException (ParamName "streamIds")
    public StreamLockedException(IReadOnlyList<object> streamIds, Exception? innerException);

    // new: never empty; the existing constructors populate it as [StreamId]
    public IReadOnlyList<object> StreamIds { get; }

    // unchanged
    public StreamLockedException(object streamId, Exception? innerException);
    protected StreamLockedException(string message, object streamId, Exception? innerException);
    public object StreamId { get; }
}

Message

The canonical message names every id when there is more than one, and gains a store-neutral remedy hint (one sentence):

  • one stream: Stream '13' may be locked for updates; retry the operation, or reduce the number of concurrent writers
  • several: Streams 'ledger/1', 'ledger/2' may be locked for updates; retry the operation, or reduce the number of concurrent writers

A list of one id gets the single-stream wording. Marten's subclass goes through the protected message constructor and keeps its own wording; Wolverine's only assertion on this message is a ShouldContain("may be locked for updates"), which still holds. The one exact-message test in this repository (LiftedStoreExceptionTests) is updated.

Not in this PR

No version bump in Directory.Build.props (this lands in 3.1.0 after 3.0.1 ships), no CHANGELOG.md entry, no change to the existing constructors or members.

Verification

  • dotnet build jasperfx.slnx -c Release
  • dotnet test --project src/EventTests -f net10.0 (full suite) and --filter-class "*LiftedStoreExceptionTests*" for the five stream_locked_* tests: the list constructor exposes StreamIds / StreamId / Id, the single-id constructor yields a one-element StreamIds, the message names all ids for several and keeps the single-stream wording for one, and the empty list is refused.

🤖 Generated with Claude Code

Additive surface so Fisher can drop its own subclass and throw the shared
type: a public constructor taking IReadOnlyList<object> streamIds (StreamId
and Id carry the first, an empty list is refused with ArgumentException) and
a public StreamIds property that the existing constructors populate as
[StreamId], so it is never empty. The canonical message names every id when
there is more than one and gains a store-neutral remedy hint. No existing
constructor or member changes shape; no version bump, this lands in 3.1.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 55cb272 into main Nov 10, 2026
3 checks passed
@jeremydmiller jeremydmiller mentioned this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StreamLockedException: add StreamIds (every stream that lost the lock) so Fisher can drop its subclass

1 participant