Skip to content

fix(render-farm): retire dead and resumed hedge tasks instead of queueing them - #4876

Open
AksharP5 wants to merge 2 commits into
CapSoftware:mainfrom
AksharP5:render-farm-hedges
Open

AksharP5 wants to merge 2 commits into
CapSoftware:mainfrom
AksharP5:render-farm-hedges

Conversation

@AksharP5

@AksharP5 AksharP5 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4874

When a worker running a speculative hedge task died or the coordinator restarted from its journal, the coordinator put the hedge task back onto the main work queue as if it were a primary chunk. Workers then rendered duplicate chunks that already had a primary task or had already completed.

Mark hedge tasks (task.hedgeOf set) as done in both requeue() and resumeJobs() instead of queueing them. If a chunk still lags later, the hedge loop spawns a fresh hedge under the normal rules.

Before / After

Scenario Before After
requeue(hedge) after worker timeout hedge.status becomes "queued" and job:v0:dup is pushed onto job.queue hedge.status becomes "done" and job.queue stays empty
resumeJobs() with a journaled primary + hedge job.queue contains ["job:v0", "job:v0:dup"] job.queue contains only ["job:v0"]; hedge is retired as "done"

Verification

  • bun run --cwd apps/render-farm typecheck
  • bun test --cwd apps/render-farm src/coordinator.test.ts (38/38 passed, including the new dead/resumed hedge regression test)
  • bun run biome check apps/render-farm/src/coordinator.ts apps/render-farm/src/coordinator.test.ts
  • node scripts/test-lint/run.mjs

Confidence Score: 5/5RetriggerView in Greptile

This PR appears safe to merge.

Summary

This PR keeps lost and resumed hedge tasks out of the regular work queue.

  • Lost and resumed hedge tasks stay out of the primary work queue.

Reviews (2) · Last reviewed commit: "fix(render-farm): allow safe replacement..." · Reviewed by Greptile

@vercel
vercel Bot temporarily deployed to Preview – cap-status December 4, 2026 17:11 Inactive
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Dec 4, 2026 5:20pm UTC

if (
!job ||
job.status !== "rendering" ||
state.duplicateOf ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Lost hedges cannot be replaced

Retiring a dead hedge leaves its primary's duplicated flag set. straggler() skips primaries with that flag, so it cannot spawn the fresh hedge promised by this fix. When the hedge worker disappears while the primary stays slow or frozen, spare workers stay idle instead of replacing the lost hedge.

Make the primary eligible for a safe replacement hedge and cover that sequence in the regression test.

Knowledge Base Used: Render-farm processing

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/render-farm/src/coordinator.ts
Line: 1552

Comment:
**Lost hedges cannot be replaced**

Retiring a dead hedge leaves its primary's `duplicated` flag set. `straggler()` skips primaries with that flag, so it cannot spawn the fresh hedge promised by this fix. When the hedge worker disappears while the primary stays slow or frozen, spare workers stay idle instead of replacing the lost hedge.

Make the primary eligible for a safe replacement hedge and cover that sequence in the regression test.

**Knowledge Base Used:** [Render-farm processing](https://app.greptile.com/-/switch-tenant?tenant=cap&next=%2Fcustom-context%2Fknowledge-base%2Fcapsoftware%2Fcap%2F-%2Fdocs%2Frender-farm-processing.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated requeue() and the expired resume-hold sweep to clear original.duplicated, preserved monotonic attempts when straggler() creates a replacement hedge, capped hedging at chunk.dispatches < PART_RANGES - 1 so replacement hedges cannot exhaust upload ranges, and extended the regression test to cover replacement dispatch and the range cap.

@vercel
vercel Bot temporarily deployed to Preview – cap-status December 4, 2026 17:20 Inactive
@AksharP5

AksharP5 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

hey @greptileai, please re-review the PR

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 75aa001f Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render farm coordinator requeues dead or resumed hedge tasks onto the main work queue

1 participant