fix(postgres): blocker-changed marks only the org whose resource changed (#1839)
deploy / plan (push) Successful in 7s
deploy / gate (push) Successful in 8m39s
deploy / agent-image (push) Canceled after 2s
deploy / dist-zip (push) Skipped
deploy / archied-image (push) Failing after 13m38s

This commit is contained in:
sam committed 2026-11-09 14:40:58 +11:00
1 parent 82313e4af5
commit 0525edd3bb
3 files changed
+10 -5

No files matched your search

@@ -869,14 +869,19 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
const markBlockerChanged = `-- name: MarkBlockerChanged :execrows
UPDATE tasks
SET park_reason = park_reason || ' [blocker changed]', updated_at = now()
WHERE status = 'parked' AND park_blocker = ANY($1::text[])
WHERE status = 'parked' AND org_id = $1 AND park_blocker = ANY($2::text[])
AND park_reason NOT LIKE '%[blocker changed]'
`
type MarkBlockerChangedParams struct {
OrgID string
Blockers []string
}
// A parked task that names one of these blockers is flagged once, so the
// operator sees the resource it waited on was edited; retry stays theirs.
func (q *Queries) MarkBlockerChanged(ctx context.Context, blockers []string) (int64, error) {
result, err := q.db.Exec(ctx, markBlockerChanged, blockers)
func (q *Queries) MarkBlockerChanged(ctx context.Context, arg MarkBlockerChangedParams) (int64, error) {
result, err := q.db.Exec(ctx, markBlockerChanged, arg.OrgID, arg.Blockers)
if err != nil {
return 0, err
}
@@ -336,5 +336,5 @@ RETURNING *;
-- operator sees the resource it waited on was edited; retry stays theirs.
UPDATE tasks
SET park_reason = park_reason || ' [blocker changed]', updated_at = now()
WHERE status = 'parked' AND park_blocker = ANY(sqlc.arg(blockers)::text[])
WHERE status = 'parked' AND org_id = sqlc.arg(org_id) AND park_blocker = ANY(sqlc.arg(blockers)::text[])
AND park_reason NOT LIKE '%[blocker changed]';
@@ -147,7 +147,7 @@ func (s *Resources) PutResource(ctx context.Context, write storecontract.Resourc
return storecontract.Resource{}, err
}
if blockers := blockersFixedBy(write.Kind); len(blockers) > 0 {
if _, err := queries.MarkBlockerChanged(ctx, blockers); err != nil {
if _, err := queries.MarkBlockerChanged(ctx, postgresdb.MarkBlockerChangedParams{OrgID: write.OrgID, Blockers: blockers}); err != nil {
return storecontract.Resource{}, err
}
}