This issue has been revealed as part of
Steps to replicate:
- Login as an admin (session 1).
- Create a course.
- Create a quiz.
- Add 2 questions to question bank (`question 1` and `question 2`).
- In order to simulate race condition hack the code and add `sleep(2);` here: https://github.com/moodle/moodle/blob/9df4a4de18ace8fa1e02b93d6f0e572fa20ef1a2/mod/quiz/locallib.php#L2160
- Open another browser tab in incognito mode and login as an admin (session 2).
- In both sessions navigate to the quiz.
- Click `Edit quiz`.
- Click `Add` -> `From question bank`.
- In session 1 tick `question 1`.
- In session 2 tick `question 2`.
- In both sessions click `Add selected questions to the quiz` at the same time.
- Confirm, that one session adds the questions and another fails due to `mdl_quizslot_quislo_uix` constraint.