fix(heartbeat): dedupe concurrent process_lost reaps - #913
Merged
Conversation
|
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. |
|
Hey @kkroo! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
Co-Authored-By: Paperclip <noreply@paperclip.ing>
kkroo
force-pushed
the
fix-heartbeat-reaper-cas
branch
from
August 1, 2026 09:54
3c0dded to
f82cdfd
Compare
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.
Thinking Path
Linked Issues or Issue Description
No standalone GitHub issue exists for this production incident. Bug details follow the bug-report template inline.
process_lost reaper dedupeandorphaned heartbeat runs process_lost; this PR is not an exact duplicate.paperclip-0logged repeatedreaped orphaned heartbeat runsmessages for the same run IDs within seconds. Thepaperclip_process_lost_totalnumerator kept increasing even though each run should only be minted asprocess_lostonce.runningheartbeat run as terminal, other concurrent reapers must observe that they lost the transition and skip metrics, wakeup finalization, retries, run events, and issue-promotion side effects.reapOrphanedRuns()calls, hold both after their active-run scan, release them together against the same dead local run, and observe that the old implementation reports/counts more than one reap.769315676c7d1ee426ef38d1b2ff8d864d1e5db7; fixed by3c0dded3711e1580307c04c7939e656938bfee44.reaped orphaned heartbeat runsrepeated for9ef9d480-1168-4bc4-958a-1dc7e1c96a3eand936a3b6f-400e-4afb-87cf-a83a8478c27ewithin seconds.What Changed
setRunStatusIfRunning()instead of the unconditional status setter.Verification
corepack pnpm --filter @paperclipai/server typecheckcorepack pnpm exec vitest run server/src/__tests__/heartbeat-process-recovery.test.ts -t "deduplicates concurrent process_lost reaps"attempted locally; the file skipped because embedded Postgres support failed to initialize on this host withPostgres init script exited with code 1. The data directory might already exist.CI should execute the test on a healthy embedded-Postgres runner.git diff --checkclaude_k8s/opencode_k8spre-adapter process_lost churn while this fix was prepared.Risks
running -> failedstill performs the existing terminal side effects.runningafter a failed CAS unexpectedly, this patch skips that reaper pass; a later periodic reap can try again.Model Used
OpenAI Codex, GPT-5 coding agent, tool-using mode with local shell, Kubernetes, Prometheus, GitHub CLI, and TypeScript typecheck verification.
Checklist
Fixes: #/Closes #OR (b) described the issue in-PR following the relevant issue template