Urgent.News

What's breaking now, across hundreds of outlets.

Tech

The message that retried hundreds of times: a retry loop with no exit

I'm Eric Gitangu. I work on backend systems for a mobility/fintech platform. This is the story of one text message that was retried hundreds of times, and what it took to teach the code to take no for an answer. The symptom A cron worker sends queued notifications. One day the SMS provider started rejecting our account as inactive. Annoying, but a provider outage is supposed to be a boring day:…

The story revolves around a single text message that was retried hundreds of times due to a retry loop with no exit. The issue began when the SMS provider rejected the system's account as inactive. Rather than expected, one queued message kept coming back, with the same recipient, across several days. Each attempt was answered with a refusal, leading to hundreds of retries.

There were three small decisions that led to this situation: the send helper had no catch, provider errors were thrown instead of returned, and the worker saved progress only after the recipient loop finished. This allowed an error to escape, leaving the row in "in progress" status, and the reclaim timer re-picked the row after a few minutes, thinking the worker had crashed.

The problem was exacerbated by the fact that the run aborted at the first failing recipient, starving the remaining recipients in the same row. The decision to keep the reclaim timer in place was made because it had good reasons for existing, but a way was needed for a row to explicitly state it had failed and not be picked up again.

To address this, a catch was added per recipient, so one bad send couldn't abort the run or hide behind others. Attempts were counted on the row itself, with exponential backoff and a cap, after which the row was marked as failed with a terminal failure and reason. The reclaim query was also taught to respect a "not before" stamp, preventing re-picking of rows with a retryAfter stamp.

The solution is a small pure class that handles three outcomes: 'sent', 'failed', and 'retry'. It doesn't perform any I/O of its own and takes everything it needs as arguments, making it easy to test. The 'retry' outcome has a reason, which is different from the 'failed' outcome. Storage errors are not swallowed and are handled separately.

Once a row is marked as failed, it is put back in the row's "already handled" list and won't be sent to again. Before the cap, failed recipients are removed from that list, allowing the next attempt to retry them. The reclaim query ensures that a row is selectable only if it has no retryAfter or the stamp is due.

The worker reads the provider's account state as a gauge, skipping sends for affected recipients if the gauge says 'down'. If the gauge is missing or unreadable, the worker treats it as up and attempts the send. Changes are logged and an alert is raised when the state flips, reducing the number of alerts.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Test browser profile isolation after attaching Playwright over CDP

When Playwright attaches to Chrome over CDP, it can see the browser's existing context. A script that opens a new tab there inherits that context's first-party storage for the origin.

  • Playwright can inspect browser contexts via CDP
  • New tab inherits context's first-party storage
  • Separate contexts prevent request collisions

My Framework Said Any: How a Pyrefly Error Led Me to Fix Typing in SwiftPY

I build SwiftPY , a Python web framework with an async Active Record ORM. Last week I opened one of my own repositories in VS Code and saw this: class DocRepository : model = Doc async def get_doc (…

  • Pyrefly error caused Any return instead of "Doc" type
  • SwiftPY fixed type chain gaps in version 0.3.8
  • Pyrefly silent import fix added in version 0.3.9

Exporting Qwen2-VL the official way: 4 dead ends and 1 error that doesn't exist on the internet

You do everything by the book. The vendor's own toolkit, the vendor's own guide, a model the toolkit claims to support. Three hundred and seventy-one build steps scroll past, all green — and then it…

  • Error "mropesection" persists across hardware and configurations
  • Qwen3-VL-2B optimization completes successfully without error
  • Qwen2-VL export issue unique to older model, no public fix

More from Friday 27 November →