Skip to content

Commit 70f270f

Browse files
committed
chore(changeset): objectql patch for the claim-race loser answer
Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
1 parent 06f9b81 commit 70f270f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql): the loser of a concurrent update answers 409 CONCURRENT_UPDATE again on an object with a metadata `beforeUpdate` hook
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Two members of a queue claiming the same parked record at the same moment again get one success and one `409 CONCURRENT_UPDATE`, as ADR-0142 D4 says. Since 18.6.0, on a single-connection store such as SQLite, the loser got `404 RECORD_NOT_FOUND` (private sharing) or `403 PERMISSION_DENIED` (public read) whenever the object carried a metadata `beforeUpdate` hook. The stored owner was always right; only the loser's answer was wrong.
11+
12+
The cause: a write on such an object opens its own unit of work, so that a refusal later in the write rolls back what a `beforeUpdate` hook wrote through `ctx.api`. That unit opened around the whole update, the authorization middleware included. On SQLite the second writer then waited for the first one's commit before its authorization gate read the record, and by then the record belonged to someone else. The unit now opens around the engine body only: the middleware runs before it, as it does for an update that opens no unit, and the hooks, the row write and the `after*` chain still run inside it and still roll back together.
13+
14+
What a middleware does after `next()` on such an update now runs after the commit, as it does on an object with no metadata hook.
15+
16+
Nothing to change in an app.

0 commit comments

Comments
 (0)