Check Whether an Operation Is Safe to Retry
Added 2026-11-01
Judge idempotency, the consequence of running twice, and the deduplication key.
Here is code or a flow that retries. Do: 1) judge whether it is idempotent and on what evidence; 2) list what a duplicate run would cause — data, notifications, billing, side effects; 3) say where a uniqueness constraint or deduplication key belongs; 4) propose an idempotency approach, choosing from idempotency keys, a state machine, conditional updates or a combination; 5) sketch a test that would catch duplicate execution. Do not assume the framework provides idempotency.
Site original
Chinese original
How to use
重试的安全性,取决于重复执行会发生什么。
Try tweaking it
- Have it restate requirements and constraints before writing code.
- Ask for the smallest change plus a rollback path, not a full-file rewrite.
What you should get
- A minimal, runnable change with copy-ready code
- Impact list: which files and call sites must follow
Common mistakes
- Asking it to touch ten files at once, then losing track of what broke what.
- Pasting only the error, with no code or version, and getting an unfixable answer.
How to check the output
- The change runs, can be rolled back, and touches nothing unrelated.
- Edge cases (empty, oversized, concurrent) are covered or explained.
Where it works
- Good for: having it restate requirements and constraints, then propose the smallest runnable change.
- Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.