Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a lock to AssessmentSubmissionService #2685

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

matthewford
Copy link
Contributor

📝 A short description of the changes

A race condition could potentially occur in the perform method of the AssessmentSubmissionService class. This method involves several operations that read from and write to the database, and if these operations are not properly synchronized, it could lead to inconsistent data.

  1. Two or more requests to submit the same assessment could be processed at the same time. This could happen if a user accidentally double-clicks the submit button, or if multiple users are working on the same assessment.

  2. The first request reads the current state of the assessment from the database.

  3. The second request also reads the current state of the assessment from the database. Because this happens before the first request has had a chance to update the database, the second request gets the old state of the assessment.

  4. The first request updates the assessment and writes the new state to the database.

  5. The second request updates the assessment based on the old state it read earlier, and writes this outdated state to the database. This overwrites the update made by the first request.

A race condition could potentially occur in the perform method of the AssessmentSubmissionService class. This method involves several operations that read from and write to the database, and if these operations are not properly synchronized, it could lead to inconsistent data.

1. Two or more requests to submit the same assessment could be processed at the same time. This could happen if a user accidentally double-clicks the submit button, or if multiple users are working on the same assessment.

2. The first request reads the current state of the assessment from the database.

3. The second request also reads the current state of the assessment from the database. Because this happens before the first request has had a chance to update the database, the second request gets the old state of the assessment.

4. The first request updates the assessment and writes the new state to the database.

5. The second request updates the assessment based on the old state it read earlier, and writes this outdated state to the database. This overwrites the update made by the first request.
Something is changing the resource before we perform the transaction, adding logging to check what it is
@matthewford matthewford marked this pull request as draft November 23, 2023 16:20
@matthewford
Copy link
Contributor Author

To be revisited after the assesmets are over

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.

1 participant