Skip to content

fix(cloud): drop tasks past payload store retention#4369

Open
grutt wants to merge 5 commits into
mainfrom
fix--drop-tasks-past-payload-store-retention
Open

fix(cloud): drop tasks past payload store retention#4369
grutt wants to merge 5 commits into
mainfrom
fix--drop-tasks-past-payload-store-retention

Conversation

@grutt

@grutt grutt commented Jul 7, 2026

Copy link
Copy Markdown
Member

Description

Resolves the FIXME in the dispatcher's populateTaskData: when bulk input retrieval fails, the dispatcher previously requeued every task in the batch regardless of whether the error was transient (e.g. an S3 rate limit) or permanent (the payload no longer exists in the external store). Tasks whose offloaded payloads are permanently gone would loop forever through assign/requeue, never reaching a terminal state. Because these zombie tasks also hold GROUP_ROUND_ROBIN concurrency slots, they can block all other work behind the same concurrency keys and build up a large backlog for the tenant.

This PR introduces a sentinel error, repository.ErrPayloadNotFound. When the dispatcher sees this error from a bulk retrieval, it retries retrieval per task and splits the batch: tasks whose payloads are permanently missing are failed non-retryably with a descriptive error message.

A companion change in the cloud S3 external store wraps NoSuchKey errors on index file fetches (and external IDs missing from an index file) with the new sentinel; it depends on this PR being released first.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

Changes have been:

  • Tested (unit, integration, or manually with steps specified)
  • Linted and formatted
  • Documented (where applicable)
  • [] Added to CHANGELOG (where applicable) -- see Keep a Changelog

🤖 AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Pull Request, in accordance with Hatchet's AI_POLICY.md.
  • Details: Claude (Cursor agent) was used to investigate the production incident that motivated this change

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Jul 10, 2026 7:44pm

Request Review

@github-actions github-actions Bot added the engine Related to the core Hatchet engine label Jul 7, 2026
@grutt grutt requested a review from mrkaye97 July 7, 2026 17:33
Comment thread internal/services/dispatcher/dispatcher.go Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-deadlock job failed on this PR (optimistic-scheduling=true). This check is non-mandatory and does not block merging, but may be worth investigating. View logs

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Optional test failure: The load-deadlock job failed on this PR (optimistic-scheduling=false). This check is non-mandatory and does not block merging, but may be worth investigating. View logs

for _, _task := range toFail {
task := _task

failGroup.Go(func() error {

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.

do we do this kind of thing concurrently in other places? just checking to make sure we're being consistent, not sure off the top of my head

Comment thread pkg/repository/payloadstore.go Outdated

// return the payloads which were found alongside the error so callers can proceed
// with the rest of the batch
return optsToPayload, &PayloadNotFoundError{Missing: missing}

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.

this sketches me out a little - feels odd to be returning both a result and an error

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

goos: linux
goarch: amd64
pkg: github.com/hatchet-dev/hatchet/pkg/scheduling/v1
cpu: AMD Ryzen 9 7950X3D 16-Core Processor          
              │ /tmp/old.txt │         /tmp/new.txt          │
              │    sec/op    │    sec/op     vs base         │
RateLimiter-8    49.50µ ± 6%   57.57µ ± 21%  ~ (p=0.132 n=6)

              │ /tmp/old.txt │         /tmp/new.txt          │
              │     B/op     │     B/op      vs base         │
RateLimiter-8   137.7Ki ± 0%   137.7Ki ± 0%  ~ (p=0.630 n=6)

              │ /tmp/old.txt │          /tmp/new.txt          │
              │  allocs/op   │  allocs/op   vs base           │
RateLimiter-8    1.022k ± 0%   1.022k ± 0%  ~ (p=1.000 n=6) ¹
¹ all samples are equal

Compared against main (0511964)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Related to the core Hatchet engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants