coder13 / coder13/LetsCube

Cut over rooms, RaceSessions, attempts, and solves to PostgreSQL

Open
#202 0 comments 0 reactions 0 assignees View on GitHub
area: data area: platform area: results enhancement priority: P1
Dominant language
JavaScript
Stars
30
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Part of #199.

## Goal

Make PostgreSQL the single source of truth for rooms, race sessions, attempts, solves, and their participant state as one coordinated aggregate.

Do not leave room state authoritative in MongoDB while session/result state is authoritative in PostgreSQL.

## Preconditions

- Production dual writes and deployment behavior from #176 are stable.
- The new schema and persistence boundary are deployed.
- #175 has backfilled historical data into the RaceSession model.
- Reconciliation shows no unexplained missing, duplicate, or mismatched records.
- A production-shaped rollback rehearsal has succeeded.

## Rollout

1. Add shadow reads that compare PostgreSQL with the current MongoDB path without returning private data in logs.
2. Measure mismatches, read latency, transaction failures, and result-submission errors.
3. Provide one aggregate-level configuration switch for authoritative PostgreSQL behavior.
4. Rehearse the switch with production-shaped data and concurrent writes.
5. Enable PostgreSQL authority in production.
6. Monitor room create/join/rejoin, session changes, attempts, solve submission/editing, expiry, and moderation.
7. Keep the compatibility path only for a bounded rollback window.

## Acceptance criteria

- [ ] Every room/session/attempt/solve read comes from PostgreSQL in authoritative mode.
- [ ] Every corresponding mutation commits to PostgreSQL before success is acknowledged.
- [ ] MongoDB failure does not affect these operations after cutover.
- [ ] Redis and Socket.IO multi-process behavior remains correct.
- [ ] Existing normal-room, private-room, reconnect, moderation, and result-outbox flows pass.
- [ ] Concurrent submissions and session switches do not create duplicates or cross-session solves.
- [ ] Metrics expose errors and latency without solve data or identity.
- [ ] Rollback triggers, procedure, and data compatibility are documented and rehearsed.
- [ ] The deployed commit and verification results are recorded.

## Non-goals

- Moving user authentication records to PostgreSQL.
- Removing the temporary migration implementation; that follows after the rollback window.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.