Skip to content

Conversation

@THE-Amrit-mahto-05
Copy link

Fixes #4830

Description

This PR fixes a race condition where multiple submissions could become public simultaneously when [is_restricted_to_select_one_submission] EvalAI/tests/unit/jobs/test_views.py:1533:4-1547:66) is enabled.
Previously, concurrent requests could bypass the check that ensures only one submission is public at a time.

Changes

[apps/jobs/views.py]
Added transaction.atomic() and select_for_update() in [challenge_submission] and [change_submission_data_and_visibility]

his ensures that the database rows are locked during the read-update operation, preventing other threads from modifying the state concurrently.

i have also added a regression test that simulates [tests/unit/jobs/test_bug_race_condition.py] the race condition using threading and mocks to verify the fix works as expected.

Verification

fixed

Confirmed that concurrent requests now correctly result in only one public submission.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant