Skip to content

Bug: Race Condition in Public Submission Toggling Allows Multiple Public Submissions #4830

@THE-Amrit-mahto-05

Description

@THE-Amrit-mahto-05

Description

When is_restricted_to_select_one_submission is enabled for a challenge phase, multiple submissions can become public simultaneously due to a race condition. This violates the business rule that only one submission should be public at a time.

Location

File: apps/jobs/views.py
Lines:

  • 342-349 (in challenge_submission function)
  • 475-485 (in change_submission_data_and_visibility function)

Reproduction

  1. Save the attached test script as test_bug_race_condition.py
  2. Run: python3 test_bug_race_condition.py
  3. Observe the output showing 2 public submissions instead of 1

Test Output:
Initial: 1 public submission(s) Final: 2 public submission(s) - IDs: [2, 3]

Expected Behavior

When a challenge phase has is_restricted_to_select_one_submission=True:

  • Only 1 submission should be public at any given time
  • When making a new submission public, the existing public submission should be made private first
  • This should work correctly even with concurrent requests

Actual Behavior

  • Multiple submissions can become public simultaneously
  • The race condition occurs because there is no database-level locking
  • Both concurrent requests pass the count() == 1 check at the same time
  • Both proceed to make their submissions public

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions