frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: How do you handle duplicate side effects when jobs, workflows retry?

4•shineDaPoker•5h ago
Quick context: I'm building background job automation and keep hitting this pattern:

1. Job calls external API (Stripe, SendGrid, AWS) 2. API call succeeds 3. Job crashes before recording success 4. Job retries → calls API again → duplicate

Example: process refund, send email notification, crash. Retry does both again. Customer gets duplicate refund email (or worse, duplicate refund).

I see a few approaches:

Option A: Store processed IDs in database Problem: Race between "check DB" and "call API" can still duplicate

Option B: Use API idempotency keys (Stripe supports this) Problem: Not all APIs support it (legacy systems, third-party)

Option C: Build deduplication layer that checks external system first Problem: Extra latency, extra complexity

What do you do in production? Accept some duplicates? Only use APIs with idempotency? Something else?

(I built something for Option C, but trying to understand if this is actually a common-enough problem or if I'm over-engineering.)

Comments

moomoo11•4h ago
You proxy those api calls yourself and have idempotency to cover you for those APIs that don’t have it. If you architect it right you won’t have more than a ms latency addition. You can avoid the race condition issues by using atomic records so if something else tries they’d see it’s in progress and exit.
babelfish•3h ago
Use something like Temporal
stephenr•29m ago
I think the answer is probably like most things: it depends.

- If the external service supports idempotent operations, use that option.

- If the external service doesn't, but has a "retrieval" feature (i.e. lookup if the thing already exists, e.g fetch refunds on a given payment), use that first.

- If the system has neither, assess how critical it is to avoid duplicates.

Tell HN: YC companies scrape GitHub activity, send spam emails to users

628•miki123211•22h ago•234 comments

Ask HN: How do you handle duplicate side effects when jobs, workflows retry?

4•shineDaPoker•5h ago•3 comments

I don't need AI to build me a new app. I need it to make Jira bearable

16•niel_hu•16h ago•10 comments

Ask HN: My competitor wants to buy us out, recommend a lawyer?

2•VladVladikoff•8h ago•1 comments

How do you evaluate a person's ability to use AI?

3•imwoody•3h ago•2 comments

1Password pricing increasing up to 33% in March

143•otterley•2d ago•195 comments

Ask HN: Who Is Using XMPP?

23•nunobrito•1d ago•11 comments

I built a 151k-node GraphRAG swarm that autonomously invents SDG solutions

2•wisdomagi•15h ago•0 comments

Ask HN: What's it like working in big tech recently with all the AI tools?

19•ex-aws-dude•1d ago•8 comments

Claude Code Bug triggers Rate limits without usage

3•busssard•20h ago•2 comments

Comparing manual vs. AI requirements gathering: 2 sentences vs. 127-point spec

3•thesssaism•20h ago•2 comments

New Claude Code Feature "Remote Control"

8•rob•2d ago•0 comments

Ask HN: What will happen with Anthropics ultimatum?

7•maniacwhat•1d ago•3 comments

Ask HN: Starting a New Role with Ada

9•NoNameHaveI•1d ago•4 comments

Ask HN: How do you know if AI agents will choose your tool?

37•dmpyatyi•3d ago•21 comments

LazyGravity – I made my phone control Antigravity so I never leave bed

4•masaTokyo•1d ago•3 comments

Ask HN: Could you create a competitor to your company at 10% of the cost?

8•TheAlchemist•1d ago•14 comments

Fix cron routes: POST → GET (Vercel cron sends GET)

2•nishiohiroshi•1d ago•1 comments

Would you choose the Microsoft stack today if starting greenfield?

20•JB_5000•3d ago•23 comments

Ask HN: How are you controlling AI agents that take real actions?

7•thesvp•2d ago•18 comments

Comparing manual vs. AI requirements gathering: 2 sentences vs. 127-point spec

7•thesssaism•2d ago•6 comments

ChatGPT finds an error in Terence Tao's math research

42•codexon•3d ago•8 comments

Ask HN: Have top AI research institutions just given up on the idea of safety?

79•DietaryNonsense•1d ago•88 comments

Ask HN: Who has seen productivity increases from AI

12•Kapura•2d ago•13 comments

Ask HN: What Linux Would Be a Good Transition from Windows 11

13•Cyberis•3d ago•20 comments

Ask HN: Any DIY open-source Alexa/Google alternatives?

9•personality0•2d ago•4 comments

Ask HN: Is it better to have no Agent.md than a bad one?

10•parvardegr•3d ago•9 comments

Persistent Prompts and Built in Search

2•lazybusy•2d ago•0 comments

Ask HN: Is it worth avoiding AI while making a game?

7•2muchclout•2d ago•22 comments

Using "Hi Claudette " on Claude.ai

4•mlongval•2d ago•3 comments