News for hackers. Stuff that matters.

shineDaPoker

This matches my thinking. The retrieval/lookup approach is exactly what I built - basically Option C with an observe-before-act pattern.

For APIs that support idempotency keys (Stripe, etc.), I use those. For ones that don't but have retrieval (most do), I check first before retrying.

The question I'm wrestling with: is the extra round-trip for the lookup worth it? Or should I just accept the edge cases where it duplicates?

What's your threshold for "critical enough to avoid duplicates"? Payments obviously yes, but what about notifications, reporting, analytics events?

I actually talked to someone in temporal about this recently. Temporal gives you the primitives to handle it (activities, configure retries, interceptors), but you still have to implement the deduplication logic yourself for each external integration.

His advice was: Temporal solves orchestration, but making the external API calls idempotent is on you. For simple cases, write observe activities manually. For complex cases, build abstraction.

That's what led me down this path - trying to figure out if the abstraction is worth building or if manual is good enough.

Have you used Temporal for this? How do you handle the idempotency of external calls?

This is exactly the approach I took. Proxy layer that: - Uses atomic records (fence tokens) to prevent concurrent execution - Checks external system first before retrying (the retrieval step) - Records result for future lookups

The atomic records part is critical - I learned the hard way that just checking a DB flag isn't enough (process can freeze between check and execute, lease expires, another process takes over, both execute).

How do you handle the case where: 1. Process acquires atomic lock 2. Calls external API successfully 3. Process freezes before releasing lock 4. Lock expires, new process acquires it 5. New process calls API again → duplicate

Do you just accept this edge case (rare but possible)? Or is there a mitigation I'm missing?

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

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 → duplicateExample: process refund, send email notification, crash. Retry does both again. Customer gets duplicate refund email (or worse, duplicate refund).I see a few...

( Read More... | 11 comments | 4 points | on HN )

Show HN: Verity – I got tired of debugging duplicate emails after job restarts

https://www.useverity.io/

Hey HN,I built Verity after debugging a production issue where our job platform was sending duplicate emails to tens of thousands of hotel guests.We were running automated checkout for a chain of hotels across Germany, Spain, and New York. The process had multiple steps: validate reservations, generate folios, check guests out, send receipt emails.The job would run for 25+ minutes processing...

( Read More... | no comments | on HN )