2.9 KiB
2.9 KiB
id, title, status, type, team, supporting_teams, roadmap_item, priority
| id | title | status | type | team | supporting_teams | roadmap_item | priority | |
|---|---|---|---|---|---|---|---|---|
| TASK-243 | Fix public snapshot scheduler job failures | done | backend | Backend Senior |
|
foundation | high |
TASK-243 - Fix public snapshot scheduler job failures
Goal
Fix the real failures found when running manual public snapshot jobs through python -m app.historical_runner --public-job ....
Context
After TASK-240 the public HTTP audit was healthy, but manual runner jobs still exposed four operational problems:
- CLI JSON serialization could crash on
datetime - ranking snapshot item persistence could fail with duplicate
player_idrows inside one snapshot - repeated PostgreSQL schema initialization could trigger deadlocks during heavy jobs
- historical monthly generation could abort if
player_event_raw_ledgerwas missing
Steps
- Reviewed the runner CLI path, ranking snapshot persistence path and historical monthly MVP V2 path.
- Added safe JSON serialization for manual job output.
- Deduplicated ranking snapshot rows by
player_idbefore item insertion. - Pre-initialized PostgreSQL snapshot storage once per heavy job and reused read/write connections without repeated DDL initialization.
- Degraded monthly MVP V2 to a controlled empty payload when
player_event_raw_ledgeris missing instead of aborting the whole job.
Files to Read First
AGENTS.mdai/architecture-index.mdai/repo-context.mdbackend/app/historical_runner.pybackend/app/rcon_historical_leaderboards.pybackend/app/historical_snapshots.py
Expected Files to Modify
backend/app/historical_runner.pybackend/app/rcon_historical_leaderboards.pybackend/app/rcon_historical_storage.pybackend/app/historical_snapshots.pybackend/app/historical_storage.pybackend/tests/test_historical_snapshot_refresh.pydocs/public-snapshot-refresh-schedule.md
Constraints
- Keep public GET endpoints snapshot-only.
- No RCON host or server configuration changes.
- No Elo/MMR reactivation.
- No Comunidad Hispana #03 reintroduction.
Validation
python -m compileall backend/appcd backend; python -m unittest tests.test_historical_snapshot_refreshcd backend; python -m unittest tests.test_current_match_payload tests.test_rcon_admin_log_storage tests.test_historical_snapshot_refresh
Outcome
- Manual public jobs now print JSON safely with datetime serialization.
- Ranking snapshot item insertion no longer tries to persist the same
player_idtwice inside one snapshot. - Heavy scheduler jobs initialize PostgreSQL snapshot storage once and then reuse non-DDL connections for the rest of the job.
- Missing
player_event_raw_ledgernow yields a controlled empty monthly MVP V2 result instead of abortinghistorical-monthly.
Change Budget
- This task exceeded the preferred tiny scope because the fixes crossed runner orchestration, persistence and regression tests.