docs(review): state check-then-act (advisory) semantics of the 409 build-lock guard honestly (#215)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 6m56s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 13s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 9m56s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 6m56s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 13s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 9m56s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Adversarial review finding 1 on PR #225: decisions.md and api-conventions §3a read as if the race were eliminated; the guard only narrows it (a queued build can acquire the lock after the check passes). Also records why true lock acquisition per mutation was not taken. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,8 +73,15 @@ hand-rolling `IActionResult` status codes:
|
||||
|
||||
When an endpoint mutates an entity that a background operation may be actively rebuilding under an
|
||||
`IEntityLocker` lock, guard the mutation and return **409 Conflict** (`ApiResults.ConflictProblem`)
|
||||
while the lock is held, rather than letting the write race the build. This mirrors the Blazor UI,
|
||||
which disables the same actions while the lock event is live.
|
||||
while the lock is held. This mirrors the Blazor UI, which disables the same actions while the lock
|
||||
event is live.
|
||||
|
||||
**This guard is advisory check-then-act, not mutual exclusion.** It narrows the race but does not
|
||||
eliminate it: a build already queued can acquire the lock a moment *after* the check passes, and the
|
||||
mutation then interleaves with the build anyway. That residual window is accepted where the
|
||||
consequences are self-healing (a playout half-mutated during a build is corrected by the next
|
||||
rebuild). If an entity's consequences were NOT self-healing, this pattern would be insufficient —
|
||||
the mutation would need to actually acquire the lock for its duration instead.
|
||||
|
||||
Established by issue #215 (`PlayoutController` + `ChannelController.ResetPlayout`): inject
|
||||
`IEntityLocker`, and at the top of every id-keyed mutation (`PUT`/`POST`/`DELETE`) check
|
||||
|
||||
+10
-2
@@ -240,8 +240,16 @@ channel. `PlayoutController` and `ChannelController` inject `IEntityLocker`; eve
|
||||
`POST .../erase-items`, `.../erase-items-and-history`, `DELETE /api/playouts/{id}`, and
|
||||
`POST /api/channels/{channelNumber}/playout/reset` — checks `IsPlayoutLocked(id)` first and returns
|
||||
**409 Conflict** (`ApiResults.ConflictProblem`, new shared helper mirroring `NotFoundProblem`) while
|
||||
the build lock is held. The PUTs are gated too (not just the destructive ops): the invariant is "no
|
||||
mutation during a build", matching Blazor's edit-disable.
|
||||
the build lock is held. The PUTs are gated too (not just the destructive ops): the target invariant
|
||||
is "no mutation during a build", matching Blazor's edit-disable.
|
||||
|
||||
- **The guard is advisory check-then-act, not mutual exclusion** — same posture as Blazor's disabled
|
||||
buttons. A `BuildPlayout` already sitting in the worker queue can take the lock a few milliseconds
|
||||
after the check passes, so the original race is *narrowed*, not eliminated; consequences remain
|
||||
self-healing (the next rebuild corrects a half-mutated playout). True prevention — having each
|
||||
mutation acquire the playout lock for its duration — was deliberately not taken: `LockPlayout`
|
||||
publishes `PlayoutUpdatedNotification` (UI churn per mutation) and would make mutations block
|
||||
builds, a semantics change out of scope for restoring Blazor parity.
|
||||
|
||||
- **`reset-all` is deliberately NOT gated** — it stays 202. `ResetAllPlayoutsHandler` already
|
||||
*silently skips* locked playouts, which matches Blazor and the handler semantics; a fire-and-forget
|
||||
|
||||
Reference in New Issue
Block a user