Skip to content

Stop truncating a projection's revision through int in StoreProjection (#5723) - #5747

Merged
jeremydmiller merged 1 commit into
masterfrom
gh-5723-long-projection-revision
Oct 23, 2026
Merged

jeremydmiller merged 1 commit into
masterfrom
gh-5723-long-projection-revision

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #5723.

DocumentSessionBase.ProjectionStorage.StoreProjection cast both values through int before assigning them to the long Revision:

r.Revision = scope == AggregationScope.SingleStream ? (int)lastEvent.Version : (int)lastEvent.Sequence;

A multi-stream projection's revision is the global seq_id, so once that passed int.MaxValue the revision wrapped negative in memory. That defeated #4526's advice to put such documents on ILongVersioned with a bigint column. Both casts are gone. An int IRevisioned member is still narrowed where the value is written back to the document; the #4614 tests pass, 9/9.

Test

EventSourcingTests.Bugs.Bug_5723_multi_stream_long_revision restarts mt_events_sequence past int.MaxValue and runs an async MultiStreamProjection over an ILongVersioned document through the continuous daemon:

  • master: Version = -2147483549;
  • here: 2147483747.

Noticed, not changed

An inline multi-stream projection does not go through StoreProjection at all. JasperFx's ApplyInline calls Store(), which auto-increments the revision instead of taking it from the event. So an inline projection's revision is a write count, not the sequence. It is pre-existing, and probably intended, but worth knowing if anyone reads ILongVersioned.Version as a sequence on an inline projection.

🤖 Generated with Claude Code

#5723)

StoreProjection cast lastEvent.Version / lastEvent.Sequence through int before assigning them to the long
Revision. A multi-stream projection's revision is the global sequence, so past int.MaxValue it wrapped
negative in memory, defeating the ILongVersioned + bigint advice from #4526. The test moves
mt_events_sequence past int.MaxValue and runs the continuous daemon: -2147483549 before, 2147483747 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 274fe43 into master Oct 23, 2026
32 checks passed
@jeremydmiller
jeremydmiller deleted the gh-5723-long-projection-revision branch October 23, 2026 17:40
This was referenced Oct 24, 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.

StoreProjection casts lastEvent.Sequence to int, so ILongVersioned multi-stream documents still overflow past int.MaxValue

1 participant