forge
Explore
Log in

Don't you dare go Hollow

📚 hold the exam lease while a course cascade sweeps sittings

Browse files at this commit

340ff4f1cc3848717c9a34a58235686322a26410Ahmet Kaan GümüşParent: 00207fe
  • fix
    • 📚 hold the exam lease while a course cascade sweeps sittings
Show full message
fix: 📚 hold the exam lease while a course cascade sweeps sittings

delete_course takes the same cascade delete_exam does — its courses'
exams and their attempts — and had the same hole: an attempt is the one
exam child whose write cannot collide with the sweep, because its claim
lands on the student's row rather than the exam's.

Narrower than the exam twin, since the delete is refused while anyone is
enrolled: a start would have to pass its enrollment gate and then have
that enrollment removed under it. Same hole, same lease. Nothing on this
path takes another lock, so it adds no ordering pair.

No test of its own — the window needs an unenroll landing inside a
start's own lease, which no sequence of HTTP calls can arrange. The
mechanism is the one regress_exam_delete already pins.
src/web/courses.rsmodified+9 -0
@@ -525,6 +525,15 @@ async fn delete_course(
525 "only the course creator or a manager/admin can delete this course",525 "only the course creator or a manager/admin can delete this course",
526 ));526 ));
527 }527 }
528+ // Writer lease of [`EXAM_LOCK`], for `delete_exam`'s reason: this cascade
529+ // sweeps the course's exams *and their attempts*, and an attempt is the one
530+ // exam child whose write cannot collide with the sweep (its claim lands on
531+ // the student's row, never the exam's). Narrower here — the delete is
532+ // refused while anyone is enrolled, so a start would have to pass its
533+ // enrollment gate and then have that enrollment removed under it — but the
534+ // hole is the same one and so is the lease. Nothing on this path takes
535+ // another lock, so it introduces no ordering pair.
536+ let _guard = crate::web::exams::EXAM_LOCK.write().await;
528 // Rows go first (the delete cascades them), blobs after — a crash in537 // Rows go first (the delete cascades them), blobs after — a crash in
529 // between strands at worst an unreachable blob. The keys are read before538 // between strands at worst an unreachable blob. The keys are read before
530 // the delete because it takes their rows with it; a refused delete just539 // the delete because it takes their rows with it; a refused delete just