Freeze pantheon community race leaderboard snapshot - #75
Conversation
Replaces the live MV with pantheon_custom_race_snapshot, drops the refresh cron, and points cheat-detection at the snapshot. Migration 012 has phased sections for manual prod rollout. Co-authored-by: Cursor <cursoragent@cursor.com>
Copied from team_pantheon_custom_race_leaderboard on prod; removes cheaters that were blacklisted after the initial 110-row capture. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Superseded by the new PR that seeds the snapshot via |
| LEFT JOIN team_activity_version_leaderboard avl USING (instance_id) | ||
| LEFT JOIN world_first_contest_leaderboard wfc USING (instance_id) | ||
| LEFT JOIN team_pantheon_custom_race_leaderboard pcr USING (instance_id) | ||
| LEFT JOIN pantheon_custom_race_snapshot pcr USING (instance_id) |
There was a problem hiding this comment.
Bug: The query in BlacklistRecentInstances joins pantheon_custom_race_snapshot without checking if the table exists, which can cause a crash if deployed before the database migration.
Severity: CRITICAL
Suggested Fix
Implement a fallback mechanism or conditional logic in the Go code to handle cases where the pantheon_custom_race_snapshot table does not yet exist. This would prevent the service from crashing if there is a delay in running the database migration. Alternatively, ensure deployment tooling strictly enforces that the migration runs before the code is active.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: lib/services/cheat_detection/database_layer.go#L265
Potential issue: The `BlacklistRecentInstances()` function in `database_layer.go`
performs a `LEFT JOIN` on the new `pantheon_custom_race_snapshot` table. The code does
not include any fallback logic or check for the table's existence. If this code is
deployed before the corresponding database migration creating the table has been run,
any call to this function will cause the cheat detection service to crash with a
"relation does not exist" error. The multi-phase rollout described for this change
increases the risk of this deployment sequencing issue occurring.
Did we get this right? 👍 / 👎 to inform future reviews.
Summary
leaderboard.pantheon_custom_race_snapshotwith 110 seeded instance IDs (frozen prod LB as of 2026-06-30).team_pantheon_custom_race_leaderboardMV (phased — see rollout).Companion: Raid-Hub/API#150
Prod rollout (no downtime)
Apply
012_pantheon_custom_race_snapshot.sqlin two phases — do not run the full file at once on prod.Phase 1 — before API deploy
Run the Phase 1 section only (CREATE TABLE + INSERT). Current API keeps reading the MV.
-- Verify: SELECT COUNT(*) FROM leaderboard.pantheon_custom_race_snapshot; -- expect 110Phase 2 — merge + deploy API first
Merge and deploy Raid-Hub/API#150. API reads
pantheon_custom_race_snapshotwith fallback to the legacy MV.Smoke test:
Phase 3 — after API deploy
Run the Phase 2 section (DROP MATERIALIZED VIEW). Merge this PR and update prod cron (remove pantheon refresh line).
Phase 4 — blacklist cleanup
Dry-run first:
Expected ~52 rows. Then apply:
Test plan
go build ./...Made with Cursor