Skip to main content

lock_for_exercise_and_user

Function lock_for_exercise_and_user 

Source
pub async fn lock_for_exercise_and_user(
    tx: &mut Transaction<'_, Postgres>,
    exercise_id: Uuid,
    user_id: Uuid,
    file_upload_ids: &[Uuid],
) -> ModelResult<Vec<AnswerUpload>>
Expand description

Like get_for_exercise_and_user, but takes a row lock on the bindings so the reaper cannot retire them between this check and the caller’s exercise_task_submission_files insert.

Must be called inside the transaction that later records the association, or the lock is released before it protects anything. Without it, a reap that lands between validation and the association commits a submission whose files are already gone: download_submission then reports zero files forever and the student never sees upload_expired.