fix(catalog-backend): prevent overlapping stitches for the same entity

markForStitching now only updates the ticket on conflict, leaving
next_stitch_at unchanged so an in-progress worker isn't interrupted.

markDeferredStitchCompleted bumps next_stitch_at to now() when the
ticket changed, so pending re-stitches happen immediately after the
current stitch finishes rather than waiting for the timeout.

performStitching no longer calls markDeferredStitchCompleted when
abandoned due to a stale ticket, since the queue entry belongs to
another worker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2026-05-22 15:00:45 +02:00
parent a3d55d7a0e
commit 0b8b67767b
7 changed files with 152 additions and 18 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Improved stitch queue semantics to prevent overlapping stitches for the same entity. New stitch requests that arrive while a stitch is in progress now only update the ticket (not the timestamp), so the in-progress worker is not interrupted. When the worker completes and detects a pending re-stitch, the queue entry becomes immediately eligible for pickup instead of waiting for the timeout period.