Skip to main content
← Back to list
01Issue
BugShippedSwamp Club
Assigneeskeeb

Relationships

#1082 score_daily rollup strands stale grains when a day-less grant re-stamps onto a later day

Opened by keeb · 7/11/2026· Shipped 7/17/2026

Found during the 2026-07-10 durability review of the #867 read-path overhaul (pre-existing, but #867 removed the last non-rollup read path, so the rollup is now load-bearing for every board).

The hazard. The score-rollup projector (services/telemetry/lib/score-rollup-projector.sql) dedups grants by grant_id and groups each grant into the (distinct_id, day, category) grain of its latest granted_at day. If a day-less grant_id — community:lab-issue:, content:feed-post:, content:extension-publish:: — is ever re-emitted with a later granted_at, the grant moves grains. The old grain's score_daily row is only rewritten if that grain is independently touched AND still has other grants producing a row; a grant that was ALONE in its grain leaves a stale row that ReplacingMergeTree can never replace (no newer version at that key) → permanent double count (history row + new-day row).

Worse: the touched CTE derives grains from toDate(granted_at) of recent rows, so the re-stamp itself never marks the OLD day as touched unless it's within today()-2.

Who is exposed. Badges are rescued by the read-side once-per-owner fold. The three day-less non-badge grant types above are not.

Suggested fix. Derive touched grains by grant_id membership (recompute every grain a touched grant has EVER lived in), or emit tombstone recomputes for touched grants' previous grains. The backfill form (score-grants-backfill.sql) is unaffected — it always recomputes everything.

Verification query (prod, one-time): count grant_ids in swamp.score_grants whose min(toDate(granted_at)) != max(toDate(granted_at)) for the three grant types — any hit is an already-stranded grain.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 8 MOREREVIEW+ 3 MOREPR_MERGED+ 1 MORENOTIFICATION_SKIPPED

Shipped

7/17/2026, 11:57:22 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
keeb assigned keeb7/17/2026, 10:18:06 PM

Sign in to post a ripple.