Skip to content

fix(usage): make rollup migrations atomic and mark late-committing finished runs - #10212

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/activity-rollup-release-review
Nov 19, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/activity-rollup-release-review

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Fixes for the review findings on release #10207 that concern the activity rollup (#10200, #10201, #10203, #10205). Both rollup flags remain off.

  • Rollup migrations are atomic again. 0461 and 0463 end the batch transaction with an embedded COMMIT for their concurrent index builds, so 0462 and 0464 ran statement by statement after them. An interrupted upgrade then failed on every retry with relation already exists. 0462 and 0464 now open a transaction first, as 0445 and 0447 do, so each file commits together with its journal row. 0465 runs inside 0464's transaction and needs no change. Schema and journal are unchanged; databases that already applied these files are unaffected.
  • Finished runs whose hour may already be computed are marked in the write that finishes them. A completion's end is stamped when the run finishes, before masking and usage recording, so its write can commit after the late-end scan has passed that end (or after the hour was computed with no late end at all). Such a cell was left to the in-flight recheck, which backs off to six hours. markFinishedRunsDirty marks, in the completion transaction, the cells of runs that started at least the settle lag less an hour ago; younger runs lie in hours not computed yet and cost nothing. The stale-execution sweep reuses one end stamp across its batches, so it marks the runs it fails the same way.
    • Reading in-flight cells live instead, as suggested on the release PR, would read every workspace-hour holding an unanswered paused run live forever (paused runs never expire), pushing large windows past the 5,000 marked-cell bound onto the legacy read. The in-flight recheck stays as the backstop.
  • A test's synthetic trigger is dropped in finally, as its neighbours do, so a failing assertion cannot leave it installed for later tests.

Test plan

  • organization-activity-rollup.integration.ts against real Postgres: 36/36. The new case commits a completion stamped behind the scan and asserts reads match the legacy read before any pass runs; it goes red with the mark disabled.
  • Migration replay: on a fresh database, an event trigger fails 0464's second statement once; the rerun succeeds with these changes and fails with relation "activity_rollup_blocked" already exists without them.
  • check:migrations, apps/sim type-check, and the logger and stale-sweep unit tests pass.

🤖 Generated with Claude Code

waleedlatif1 and others added 2 commits November 19, 2026 10:52
…p migrations atomic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e redundant 0465 BEGIN

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 19, 2026 7:02pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

This PR changes a database schema or migrates data. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

This PR makes rollup migrations atomic and marks older finished runs so activity reads do not wait for a later recheck.

  • Finished runs mark old activity hours for refresh.
  • Rollup migrations keep schema changes and journal entries together.
  • The rollup integration test always removes its failure trigger.

No new actionable issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "fix(usage): lock activity rollup marks i..." · Reviewed by Greptile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 627d213 into staging Nov 19, 2026
82 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/activity-rollup-release-review branch November 19, 2026 19:32

This branch was previously deployed

1 inactive deployment
Preview — afcba354 Deployed Nov 19, 2026 by vercel[bot]
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.

1 participant