Idempotency means that doing something twice has the same effect as doing it once. Automations without it produce duplicate emails, double payments and repeated records, and retries make the problem worse.
Why do duplicate runs happen?
- Retries. After an apparent failure that actually succeeded.
- Overlapping schedules. A run starting before the last finished.
- Manual reruns. After an incident.
- Duplicate triggers. The same event delivered twice.
Which is most common?
Retry after a timeout. The action completed and the confirmation was lost, so the system retries something that already happened, which is precisely how duplicate messages get sent.
What makes an operation safe to repeat?
Checking before acting, or using an identifier the receiving system recognises. Either means a second attempt does nothing rather than doing it again.
What is a unique key?
An identifier derived from the item being processed, sent with the operation. The receiving system rejects a second request carrying the same key, which makes retries safe without any logic on your side.
What about the check-first approach?
Simpler and slightly weaker. Looking for an existing record before creating one works well in practice and has a small window where two simultaneous runs could both pass the check.
What about recording what you did during an incident?
Worth doing at the time rather than afterwards. Reruns, manual fixes and skipped items are all easy to forget, and reconstructing them later during a reconciliation is considerably harder.
A few lines noting what was rerun and when is enough. It also helps the next incident, since the same problem tends to recur and the notes are a faster route to the fix than diagnosing again.
Which operations need this most?
Anything with an external effect: sending, paying, creating records, posting. Reading is naturally safe to repeat, and everything else deserves a thought.
How do you record what has been processed?
By marking items as done, in a place the automation reads before starting. That single pattern prevents most duplication and makes reruns after a failure straightforward.
What about partially completed runs?
Where this matters most. An automation that failed halfway through fifty items should resume at item twenty-six, and it can only do that if it recorded progress.
What about recording before acting?
The sequencing that makes recovery possible. Marking an item as being processed before the action, and as complete afterwards, means an interrupted run leaves evidence of where it stopped.
Recording only on completion produces ambiguity. An item with no marker might never have been attempted or might have been completed just before the failure, and telling those apart afterwards is frequently impossible.
What about external systems that are not idempotent?
The awkward case, and it happens. Some services will happily accept the same request twice and act on it both times, with no identifier mechanism to prevent it.
The workaround is recording on your side. Marking an item as sent before the call, and checking that marker before retrying, moves the protection to the place you control, which is imperfect and considerably better than nothing.
What does this enable?
Confident reruns. An automation you can safely run again after any failure is dramatically easier to operate than one where every incident requires working out what already happened.
Letting it sort rather than decide captures most of the saving and keeps judgement with somebody who can be held to it.
What is the practical advice?
Mark items as processed, check before acting, and use provided identifiers where a service offers them. Three habits, and they turn a scary rerun into a routine one.