5 ms·
> the client should just error out and stop processing and return the error to the user, who will have more context and knows whether or not a retry is necessar
by azylman 7y ago
> the client should just error out and stop processing and return the error to the user, who will have more context and knows whether or not a retry is necessary or desirable... Even banks do that. It's fine
If a user at a bank tries to transfer $10,000, gets an internal server error and retries because their balance hasn't updated (banks don't process these in realtime), and checks the next day and finds $20,000 gone, that's a big problem. The user can't be responsible for this, you need something more.
You're not wrong that this isn't necessary in the majority of cases (updating your email address?) - but the majority of cases don't need distributed systems. By the time you're talking about distributed systems (which is the focus of this article and discussion), you absolutely do need this, in the vast majority of cases.
- ubu7737 7y agoAvoiding duplicate processing is a very big part of compliance in banking transactions. Making mistakes in this area is somewhat common but very punitive for the institution that makes the mistake. As a result, design priorities are heavily skewed toward exactly-once processing of financial transactions.
- foota 7y agoEh, in that case you're asking for trouble by requiring the server to be successful. If I had to write an API like that I would definitely go with randomized tokens per logical request for dedupe on retries. If it's a user facing transaction it should be a transaction resource that's created and then the server does the retries imo, with the user able to view the status.
- azylman 7y agoExactly, given a timeout you can't assume the server is clearly successful (or unsuccessful!). That was my point, we're definitely agreeing :) Usually you'd generate some kind of idempotency key (randomized token as you said) and retry with that. You definitely can't just bubble that up to the user and assume things are fine