Repository navigation
fix: cap incident issue load in agent-run context to prevent unbounded IN clause #SUPERLOG - #538
Open
superlog-app[bot] wants to merge 1 commit into
Open
superlog-app[bot] wants to merge 1 commit into
superlog-app[bot] wants to merge 1 commit into
Conversation
…d IN clause #SUPERLOG Delivery-Id: 4edfa37d3357f2b56f3f44a51f5c782bef5ace93a093263f2dd1ab0154c1511a Delivery-Base: main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent PR delivery stalled completely after the worker restart at 22:05 UTC (incident
knotty-manatee). Three independent metrics confirmed zero deliveries:superlog.prs.created,superlog.agent_pr_delivery.guard, andpr_observability.review_passesall flatlined, while agent investigations kept running at above-baseline rate. The worker emitted noapi.github.comcalls across 115 minutes of runtime.Root Cause
In
loadAgentRunContext, the two-step issue-loading query is unbounded:When an incident accumulates many linked issues, the
inArraycall grows proportionally. Production logs showed 13,854+ bind parameters (the log line was itself truncated at 30 kB, so the actual count may have been higher). Postgres rejects queries that exceed its 65,535 bind parameter limit with a hard "Failed query" error. The failure is caught inqueue.tsand logged as"agent-run advance failed; the next sweep re-enqueues it"— but the next sweep calls the same unboundedloadAgentRunContextagain, creating a permanent retry loop that prevents any advance from succeeding and blocks all PR delivery.Remediation
Add a JOIN on
issuesto the first query so rows can be sorted bylastSeen DESCbefore applying aLIMIT 200. The secondinArraycall is now bounded at ≤ 200 parameters, well under the Postgres limit. The 200 most-recently-seen issues are always included, matching existing downstream caps (MAX_TRACE_ENRICHED_ISSUES = 50inprompt-context.ts).Typecheck: ✅
tsc --noEmitpassesTests: ✅
test:agent-run-queue,test:agent-run-startpassRelated incident:
c7813ad1-000c-4ee0-b76d-d1b7b3707d03Was this PR helpful? Leave feedback — goes straight to the Superlog team.