forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to tests/partial_patch_subjects.rsClear filter

2026-07-25

fix: 🧩 finish the partial-PATCH sweep — 4 more handlers lost writesAhmet Kaan Gümüş · d773e7e
fix: 🧩 finish the partial-PATCH sweep — 4 more handlers lost writes

32bca26 routed six resources through `FieldUpdate` so a PATCH writes only
the fields it was given. It stopped at six of ten. The remaining four
still read the row unguarded and then wrote a field-scoped `SET` bound to
that stale snapshot, so two concurrent PATCHes of different fields
reverted each other, 200 OK, silently:

- subjects and the two user routes (`apply_profile`/`apply_preferences`,
  four endpoints) move to `FieldUpdate`. No lock needed — neither has a
  cross-field check, so request-scoped values alone close it
- course sessions get `SESSION_LOCK`, taken *before* the row read
  whenever `starts_at`/`ends_at` arrives, with the range merged and
  revalidated against the stored other end. The lock is not optional:
  converting to `FieldUpdate` without it re-introduces 9e25e0c, verified
  by disabling it and watching a one-ended PATCH store
  `starts_at > ends_at` with both requests answering 200
- bank questions instead take `BANK_LOCK.write()` before `owned_question`.
  This one is a genuine read-modify-write — the kind/choices/correct
  trio must merge from the stored row because choice ids carry the option
  pictures — so an exclusive lease over read+merge+write is the fix, the
  same shape as the exam PATCH. Per-field writes cannot express it
- `subject.rs` also mints ids via `monotonic_id::next_ulid()` now, since
  subjects list `ORDER BY id ASC`; `bank_questions.rs` rustdoc stops
  calling a choice id a position

Also verified safe and left alone: the exam and exam-question PATCHes
already hold `EXAM_LOCK.write()` across read and write, settings uses a
CAS retry, and messages/chatbot/questions/appointments write single
fields.

Each new suite races 20 rounds and reads the row back; every one fails if
the stale refill is restored.