You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we need to ebuild Redis event headcounts from MongoDB on server startup to recover from potential Redis data loss.
Redis stores per-event seat counts (headcount key) for capacity-limited events. If the Redis data volume is deleted or AOF is corrupted, the headcount resets to zero and seats appear available again even when they're not. Redis is configured with AOF persistence and a Docker volume, so this is mainly a safety net, not a hot path.
general approach:
On server startup, before the HTTP server starts, run a one-time sync routine
For each event where max_attendees != -1:
Count accepted registrations for that event in MongoDB
SET the Redis headcount key with current capacity = max_attendees
DECR the headcount by the number of accepted registrations
This is idempotent — running it multiple times is safe (sets headcount to correct current value)
Only runs for events that exist — no cleanup of stale Redis keys needed (they're harmless)
notes:
we probably need a new function in pkg/db/redis.go or a separate startup reconciler
we call it once in cmd/server/main.go after Redis connects, before routes start
CONTEXT
general approach:
max_attendees != -1:SETthe Redis headcount key with current capacity =max_attendeesDECRthe headcount by the number of accepted registrationsnotes:
pkg/db/redis.goor a separate startup reconcilercmd/server/main.goafter Redis connects, before routes start