Skip to content

Redis seat count reconciliation on startup #145

@steeevin88

Description

@steeevin88

CONTEXT

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions