fix(people): portable dirty-mark upsert (prod 500 on person mutations, 0 suggestions) #768

Merged
chris merged 1 commit from fix/dirty-mark-pg-merge into main 2026-09-19 13:22:21 +02:00
Owner

Production regression from #760: FaceRecognitionDirtyMarkService.markDirty used an ANSI MERGE with an aliased target in the WHEN MATCHED SET clause — H2 (CI) accepts it, PostgreSQL rejects it: 'column d of relation face_recognition_dirty does not exist'. Consequences on prod since #760/#761: every person mutation that marks dirty 500-ed (remove-from-person, candidate accept, merge, rename, occurrence confirm/move — user-reported remove 500), face_recognition_dirty stayed empty (0 rows), the reconcile scheduler never re-armed recognition → 0 suggestions.

Also not portable: a single-statement INSERT ... ON CONFLICT DO UPDATE (H2 in the regression suite rejects DO UPDATE — verified). Fix: two portable statements (UPDATE, then INSERT when nothing changed) — identical semantics on PG and H2, serialized per owner by the caller's edit transaction.

Verified: prod SQL smoke test + targeted H2 test classes green.

Production regression from #760: FaceRecognitionDirtyMarkService.markDirty used an ANSI MERGE with an aliased target in the WHEN MATCHED SET clause — H2 (CI) accepts it, PostgreSQL rejects it: 'column d of relation face_recognition_dirty does not exist'. Consequences on prod since #760/#761: every person mutation that marks dirty 500-ed (remove-from-person, candidate accept, merge, rename, occurrence confirm/move — user-reported remove 500), face_recognition_dirty stayed empty (0 rows), the reconcile scheduler never re-armed recognition → 0 suggestions. Also not portable: a single-statement INSERT ... ON CONFLICT DO UPDATE (H2 in the regression suite rejects DO UPDATE — verified). Fix: two portable statements (UPDATE, then INSERT when nothing changed) — identical semantics on PG and H2, serialized per owner by the caller's edit transaction. Verified: prod SQL smoke test + targeted H2 test classes green.
fix(people): portable dirty-mark upsert (PG MERGE alias rejected, H2 ON CONFLICT DO UPDATE rejected)
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 3m18s
cbbcd32fa7
markDirty used an ANSI MERGE with an aliased target in the WHEN MATCHED
SET clause (d.marked_at): H2 accepts it, PostgreSQL rejects it
('column d of relation face_recognition_dirty does not exist'). Every
person mutation that marks dirty 500-ed on production since #760 —
candidate accepts, occurrence remove/confirm, merge/rename/dissolve —
leaving face_recognition_dirty empty, so the reconcile scheduler never
re-armed recognition (0 suggestions) and remove-from-person 500-ed.

A single-statement ON CONFLICT DO UPDATE is also not portable (H2 in the
test suite rejects DO UPDATE). Replace with two portable statements:
UPDATE first, INSERT when nothing changed — serialized per owner by the
caller's edit transaction, identical semantics on both engines.
chris merged commit f1b4c0ce77 into main 2026-09-19 13:22:21 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!768
No description provided.