Compare commits

...

1 Commits

Author SHA1 Message Date
Jiayuan Zhang
200d26413b fix(db): relax pending task unique index to per-(issue, agent)
The idx_one_pending_task_per_issue index only allowed one pending task
per issue across all agents, causing different agents' queued/dispatched
tasks to block each other. This mismatched the code-level dedup which
checks per (issue_id, agent_id). Replace with idx_one_pending_task_per_issue_agent
on (issue_id, agent_id) so each agent can independently have one pending task.

Fixes MUL-495

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 15:41:34 +08:00
2 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
DROP INDEX IF EXISTS idx_one_pending_task_per_issue_agent;
CREATE UNIQUE INDEX idx_one_pending_task_per_issue
ON agent_task_queue (issue_id)
WHERE status IN ('queued', 'dispatched');

View File

@@ -0,0 +1,8 @@
-- Fix: the old index only allowed one pending task per issue across ALL agents.
-- This caused different agents' pending tasks to block each other.
-- Change to per-(issue, agent) so each agent can independently have one pending task.
DROP INDEX IF EXISTS idx_one_pending_task_per_issue;
CREATE UNIQUE INDEX idx_one_pending_task_per_issue_agent
ON agent_task_queue (issue_id, agent_id)
WHERE status IN ('queued', 'dispatched');