Add per-issue Redis locks for distributed agent dedup - #731
Conversation
PR Summary by QodoAdd per-issue Redis locks to deduplicate distributed agent work
AI Description
Diagram
High-Level Assessment
Files changed (17)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
7 rules 1.
|
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit ccd095a |
majamassarini
left a comment
There was a problem hiding this comment.
LGTM! I just don't understand the comment removal in triage_agent.py code. But I suppose you didn't like them.
Sorry, I thought they are no longer relevant and that's why Claude removed them. Reverted. |
Introduce ymir/common/issue_lock.py with `SET NX PX` acquire, Lua `compare-and-delete` release, Lua `compare-and-PEXPIRE` extend, a heartbeat loop at TTL/3, and an async context manager that ties them together. Yields `None` when the lock is already held so callers can use a guard-clause pattern. If the heartbeat detects the lock was lost (Redis outage > TTL), it logs an error but does not cancel the running task — the Jira in-progress label acts as a fallback dedup anchor. The lock prefix is parameterizable (default `lock:triage:`) so downstream agents can use their own namespace. Signed-off-by: Nikola Forró <nforro@redhat.com> Assisted-by: Claude Opus 4.6 via Claude Code
Wrap triage_agent's process_task in issue_lock so two workers cannot process the same Jira issue concurrently. The fetcher now also checks for active lock keys before enqueuing, closing the TOCTOU window from both sides. Lower `run_task_loop`'s default poll_timeout from 30s to 5s — this determines how long `BRPOP` blocks and directly eats into the termination grace period. All agents benefit from the faster shutdown response. Deployment changes: - terminationGracePeriodSeconds 45 → 90 - strategy Recreate → RollingUpdate (maxSurge 1, maxUnavailable 0) Signed-off-by: Nikola Forró <nforro@redhat.com> Assisted-by: Claude Opus 4.6 via Claude Code
Same pattern as triage: acquire a Redis lock keyed by Jira issue immediately after parsing the payload; drop duplicates if the lock is already held. Each agent uses its own lock prefix (`lock:rebase:`, `lock:backport:`, `lock:rebuild:`) so different pipeline stages can process the same issue concurrently. Deployment changes for all 6 agent variants: - terminationGracePeriodSeconds 45 → 90 - strategy Recreate → RollingUpdate (maxSurge 1, maxUnavailable 0) Signed-off-by: Nikola Forró <nforro@redhat.com> Assisted-by: Claude Opus 4.6 via Claude Code
| f"{consolidated.issue_key}: {e}" | ||
| ) | ||
|
|
||
| # Dispatch to downstream queues |
There was a problem hiding this comment.
Why the comment removals, aren't they valid any more?
There was a problem hiding this comment.
I've just notice the other review.
SET NX PXwith a heartbeat loop and Lua-based release/extend, so two workers never process the same Jira issue concurrentlypoll_timeoutfrom 30s to 5s for faster graceful shutdown across all agentsterminationGracePeriodSeconds: 45 → 90,strategy:Recreate→RollingUpdate(maxSurge: 1,maxUnavailable: 0)