971 B
971 B
TODO
Distributed global cap for phantom users (multi-process safe)
- Add DB-backed quota as source of truth (
system_quotastable, rowphantom_userswithusedandlimit). - Move cap enforcement into one DB transaction:
- lock quota row with
SELECT ... FOR UPDATE - check
used < limit - create phantom user
- increment
used - commit (or rollback on failure).
- lock quota row with
- Handle same-email races using
UNIQUE(email):- on duplicate key, do not increment quota
- return existing user (or unified error response).
- Add periodic reconciliation job:
- recalculate phantom count from
users - repair
system_quotas.usedif drift is detected.
- recalculate phantom count from
- Move phantom creation rate-limits to shared backend (Redis or DB atomic counters), so all server processes enforce the same limits.
- Add concurrency tests:
- multi-process create storm near cap boundary (499/500)
- duplicate-email storm
- assert
used <= limitalways holds.