fix(catch_error): re-stamp on_failure message so a late callback is not age-dropped - #405
Open
alienard-wiremind wants to merge 1 commit into
Open
fix(catch_error): re-stamp on_failure message so a late callback is not age-dropped#405alienard-wiremind wants to merge 1 commit into
alienard-wiremind wants to merge 1 commit into
Conversation
…ot age-dropped CatchError re-enqueues the on_failure message from a dict re-materialised via Message(**on_failure).copy(...), which preserved the original message_timestamp (and message_id). When the on_failure message carries a max_age and is attached to a message that retried or aged for a long time, it was born already expired, so AgeLimit dropped it at consume time and the callback never ran. Re-stamp the re-enqueued message with a fresh message_id and message_timestamp so it is treated as freshly enqueued, matching the string-actor-name on_failure path (which builds a fresh message via actor.send). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
T'en penses quoi @thomasLeMeur ? |
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.
Problem
CatchError.after_process_messagere-enqueues theon_failuremessage from a dict re-materialised viaMessage(**on_failure).copy(...).copy(attr.evolve + option-merge) preserves the originalmessage_timestampandmessage_id— the ones from when theon_failuremessage was built, which can be long before the failure it reports.When the
on_failuremessage carries its ownmax_age(a common pattern for batch callbacks) and is attached to a message that retried or aged in a delay queue for hours, the re-enqueued callback is born already past its age limit.AgeLimit.before_process_messagethen drops it at consume time and the callback never runs — silently.This was hit in production: a batch's ~884 hard failures escalated/retried into a delay queue overnight; when they finally failed terminally the next morning, every
on_failurecallback was enqueued with its ~13–20h-old build timestamp and immediately age-dropped into the dead-letter queue, so the downstream system was never notified.Fix
Re-stamp the re-enqueued
on_failuremessage with a freshmessage_idandmessage_timestampso it is treated as freshly enqueued. This matches the string-actor-nameon_failurepath, which already builds a fresh message viaactor.send. The callback is a leaf message (nopipe_target), so a fresh id is safe.Test
test_on_failure_stale_message_is_restampedreproduces the bug: anon_failuremessage with a smallmax_ageand a backdatedmessage_timestampis dropped byAgeLimitbefore the fix and runs after it. Verified it fails on the pre-fix code and passes on the fixed code; fulltest_catch_error.pysuite green; ruff + mypy clean.Notes
Unreleased/ Fixed entry — please assign a version at tag time.Pipelines) re-materialises its dict with the original timestamp too; the same staleness can affect long-backlogged pipelines. Not addressed here — flagging for a possible follow-up.