[codex] fix(github-webhook): bound reviewer-wake lock retries (BLO-21582) - #1266
[codex] fix(github-webhook): bound reviewer-wake lock retries (BLO-21582)#1266kkroo wants to merge 2 commits into
Conversation
|
🔗 Paperclip issue: BLO-21582 |
1 similar comment
|
🔗 Paperclip issue: BLO-21582 |
ad9e953 to
4735bdd
Compare
|
@ally please review exact head This is the rebased single-commit human-authored successor to #1003. Verification on this head: 71 runnable webhook tests passed (59 DB-backed skips on macOS), server typecheck passed, diff check passed, and the commit-attribution gate passed. The prior workspace/UI failure was unrelated to these two server files. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 4735bdd
Critical Issues (0)
Important Issues (1)
- [gstack/review]
server/src/routes/github-webhook.ts:1794— The request-wide lock budget is not actually end-to-end bounded.statement_timeoutis per statement, but the code sets it once before bothBEGINand the advisory-lock probe. IfBEGINstalls for almost 4s then succeeds, the probe gets another nearly 4s timeout before the deadline check; the fallback path has the same issue. This can again push webhook latency toward GitHub's response timeout under database contention.- Recompute and apply the remaining deadline immediately before each potentially blocking statement, and add coverage for a delayed
BEGINfollowed by a delayed probe.
- Recompute and apply the remaining deadline immediately before each potentially blocking statement, and add coverage for a delayed
Suggestions (0)
Strengths
- The reserved-connection approach avoids running a detached transaction after pool checkout times out.
- The lock-exhaustion paths now preserve the delivery-funnel accounting and distinguish durable duplicate wakes from losses.
Recommended Action
- Address the Important timeout-boundary issue before merge.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
4735bdd to
3ba6da4
Compare
|
@ally please re-review exact head Addressed the P2 by re-arming Verification on this head: 73 runnable webhook tests passed (59 embedded-Postgres skips on macOS), server typecheck passed, diff check passed, and commit attribution passed. |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 3ba6da4
Prior Findings Dispositioned (1)
- prior:4735bdd important 1 — fixed —
server/src/routes/github-webhook.ts:1750—applyRemainingStatementTimeoutderives the remaining time from the original absolute deadline, and the lock path reapplies it before bothBEGINand the advisory-lock probe at lines 1830-1837.
Critical Issues (0)
Important Issues (0)
Suggestions (0)
Strengths
- The reservation-based implementation avoids detached transaction work after pool-checkout contention.
- The new deterministic tests cover both a delayed
BEGINand fallback queries consuming the request-wide budget.
Recommended Action
- Merge when the queued checks complete successfully.
allyblockcast
left a comment
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 3ba6da4
Prior Findings Dispositioned (1)
- prior:4735bdd important 1 — fixed —
server/src/routes/github-webhook.ts:1750—applyRemainingStatementTimeoutderives the remaining time from the original absolute deadline, and the lock path reapplies it before bothBEGINand the advisory-lock probe at lines 1830-1837.
Critical Issues (0)
Important Issues (0)
Suggestions (0)
Strengths
- The reservation-based implementation avoids detached transaction work after pool-checkout contention.
- The new deterministic tests cover both a delayed
BEGINand fallback queries consuming the request-wide budget.
Recommended Action
- Merge when the queued checks complete successfully.
…merge-20260814 # Conflicts: # server/src/routes/github-webhook.ts
|
@ally head Requested a review from @allyblockcast directly (native GitHub review request, not just this comment) against current head |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 4ac2309
Critical Issues (0)
Important Issues (0)
Suggestions (0)
Strengths
- Uses an absolute request deadline across pool reservation, transaction setup, advisory-lock probes, and fallback reads.
- Avoids detached database work by releasing late reservations before issuing SQL and awaiting actions after lock acquisition.
- Adds focused unit and embedded-Postgres coverage for contention recovery, fallback timeout behavior, and cleanup while contention remains.
Recommended Action
- Merge when the required CI checks are green.
- No Critical or Important review findings.
Superseded by #1155 (BLO-21995) — closing as obsolete, not as rejectedThis is a correct, approved implementation of a fix that landed independently 9 days earlier and has been in production since 2026-08-20. Closing it so an approved-at-head PR cannot re-introduce a second, parallel bounding layer into the reviewer-wake router. Evidence
Master carries the whole capability set this branch adds, under different identifiers — which is why a token grep for this branch's names returns 0 on master and reads misleadingly as "not upstream":
Honest residual delta — this is not a perfect supersetThis branch additionally applies a SQL statement timeout to the lock probe and fallback reads ( Because master rewrote the same functions (+791/-140), that delta would have to be re-implemented against current master, not rebased: a trial squash-linearize produced 9 conflict hunks (8 in No force-push and no rebase was performed on this branch; the trial was in a throwaway clone. Reopen if you disagree: the approval is genuine and the code is sound, the only objection is that the problem is already solved upstream. — CTO, BLO-21582 |
Thinking Path
Linked Issues or Issue Description
No GitHub issue exists for this control-plane incident. Related Paperclip issue: BLO-21582.
Related PRs: #1003 is the App-authored original this draft supersedes; #1155 is a separate App-authored durable-retry approach for a later issue.
What happened: under per-PR lock or connection-pool contention, a reviewer wake could time out before the normal
receivedmetric was recorded. The webhook still returned HTTP 200, so GitHub did not redeliver the loss. A JavaScript timeout arounddb.transaction()also could not cancel a late pool checkout or query.Expected behavior: lock acquisition and lock-exhaustion rechecks stay bounded, an abandoned reservation never runs detached SQL, an equivalent concurrent wake is not falsely dead-lettered, and a real loss is recorded as
receivedplusdead_lettered.Reproduction: hold the per-PR advisory lock or saturate the application pool while delivering a reviewer-triggering PR webhook. The new route tests exercise transient contention, exhausted contention, a blocked fallback read, and pool-checkout starvation.
Affected environment: current
master(82154e5c) with PostgreSQL-backed reviewer wakes.What Changed
statement_timeoutbounds.BEGINand cleared before release.Verification
pnpm --filter @paperclipai/server typecheck— passed.pnpm exec vitest run server/src/__tests__/github-webhook.test.ts -t 'bounds fallback transaction setup' --reporter=verbose— passed (1 selected test).afterAllcleanup timed out after 60 seconds.mastercomparison: all 120 assertions passed and reproduced the sameafterAlltimeout, establishing that cleanup failure as baseline test-harness behavior rather than this change.Risks
statement_timeout; the implementation resets the timeout unconditionally before releasing each connection.Model Used
OpenAI GPT-5 Codex, using tool-assisted repository analysis, GitHub inspection, implementation, and local verification.
Checklist