Skip to content

Retry ack for claimed work items - #1851

Open
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/poller-retry-claimed-ack
Open

Retry ack for claimed work items#1851
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/poller-retry-claimed-ack

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Retry acknowledgment for the work item that was already claimed before polling for another item.

iter_work() and aiter_work() currently handle a transient work.ack() failure by backing off and then continuing the outer polling loop.

The current sequence is:

  1. poll() claims work_1;
  2. ack(work_1) fails transiently;
  3. back off;
  4. poll() again.

The original item is never acknowledged or yielded before the worker resumes polling.

Fix

Keep the claimed item in hand and retry its acknowledgment in an inner loop.

For sync and async pollers:

  • transient failures retry ack() for the same work_id;
  • no new poll() occurs between attempts;
  • success resets the ack backoff and yields the original item;
  • permanent 4xx failures retain the existing force-stop behavior;
  • polling and stop semantics otherwise remain unchanged.

Regression coverage

Adds deterministic sync and async tests where the first ack returns a transient 500 and the second succeeds.

The tests require the operation order:

poll, ack, ack

and fail if a second poll() occurs before acknowledgment succeeds.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 17, 2026 08:49
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.

1 participant