Repository navigation
feat(vahter): /rebuild-snapshots backfills aggregate user snapshots (?scope=users) - #523
Merged
Merged
Conversation
…?scope=users Snapshots are otherwise written lazily, so each heavy user's first load after a deploy (or a SchemaVersion bump) still pays one full replay. The existing admin rebuild already replays every user stream; it now also force-writes the aggregate snapshot via the new EventStore.RebuildSnapshot (full replay that ignores and repairs the stored snapshot). ?scope=users skips the heavy message/moderation read-model pass; unknown scopes are rejected with 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
Aggregate snapshots (#518) are written lazily, so each heavy user's first load after a deploy still pays one full replay. That's the 4.56 s @fvnever span on the dashboard. 190 users with ≥20 events are still unsnapshotted in prod (31 with ≥100, 6 with ≥300, max 962).
What
EventStore.RebuildSnapshot(fold, zero, policy, streamId): replays the whole log (ignoring any stored snapshot) and force-writes the snapshot when the stream has ≥SnapshotEveryevents. It works as both a backfill and a repair, e.g. of a wrong snapshot at the same version. It uses its owneventStore.snapshotRebuildspan, and a failed write is recorded and swallowed like elsewhere.POST /rebuild-snapshotsuser phase already replayed every user stream; it now also writes the aggregate snapshot. No temporary endpoint, nothing to clean up.?scope=usersruns only the user phase and skips the heavy message/moderation read-model pass. An unknown scope returns 400.Tests (red → green)
LoadState: 1000 vs 325); rebuild skips streams belowSnapshotEvery.POST /rebuild-snapshots?scope=userswrites the aggregate snapshot for a 26-event user (correctUserstate) and doesn't build the message snapshot (red before: no snapshot row).After deploy
🤖 Generated with Claude Code