catalog: remove stitch_ticket from final_entities, use two-ticket model in stitch_queue

Replace the single stitch_ticket column in final_entities with a two-ticket
model (latest_ticket + active_ticket) in stitch_queue for optimistic
concurrency control. When picking up stitch work, active_ticket is set to
latest_ticket. Before writing results, the stitcher checks that latest_ticket
hasn't changed. This fully decouples stitching concurrency from final_entities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
Fredrik Adelöw
2026-03-05 23:03:38 +01:00
parent 7416e8b0c0
commit bf59528fb9
19 changed files with 181 additions and 115 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/plugin-catalog-backend': patch
---
Moved stitch queue columns (`next_stitch_at`, `next_stitch_ticket`) from `refresh_state` into a dedicated `stitch_queue` table with `entity_ref` as the primary key. When a stitch completes successfully, the corresponding row is deleted from the queue. The migration handles existing data and is fully reversible.
Moved stitch queue concerns out of `refresh_state` and `final_entities` into a dedicated `stitch_queue` table with `entity_ref` as the primary key. The stitch queue uses a two-ticket model (`latest_ticket` and `active_ticket`) for optimistic concurrency control. When a stitch completes successfully and the ticket hasn't changed, the corresponding row is deleted from the queue. The migration handles existing data and is fully reversible.