Skip to content

Race Condition in Access Code Generation for Quiz聽#140

Description

@TheCodeHeist-Coder

馃搷 Location
/apps/http-server/routes/api/v1/quizzes/:quizId/generate-access-code

Problem Description

The current implementation of the access code generation endpoint is vulnerable to a race condition when multiple users request a code simultaneously.

Scenario:
User A and User B send a request at the same time
Both requests execute generateCode()
Both receive the same generated code (e.g., AC123A)
The system assigns duplicate access codes

This leads to non-unique access codes, which breaks the assumption that each quiz session should have a unique join code.

Expected Behavior

  • Each generated access code must be globally unique
  • Concurrent requests should never result in duplicate codes
  • The system should handle collisions gracefully (e.g., retry mechanism)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions