(no title)
dilatedmind | 4 years ago
my approach has been to make all operations idempotent and ensure they are all ran at least once.
dilatedmind | 4 years ago
my approach has been to make all operations idempotent and ensure they are all ran at least once.
adanto6840|4 years ago
hderms|4 years ago
1. User clicks "buy now" for whatever is in their shopping cart 2. Client generates some kind of transaction ID representing that they wanted to purchase the contents of the shopping cart (could be deterministic ID) 3. Client submits this request to the server 4. Server persists the intention to start processing the purchasing of the shopping cart with transaction ID of X 5. Server synchronously or asynchronously starts handling the side effects of the purchase 6. If at some point the client got an error message it can still submit the same request with the same transaction ID to retry and even if the initial request was received (but perhaps lost before getting to the client) it's cheap and easy to make it idempotent by using the transaction ID
Race conditions would be made more difficult by having everything idempotent based on the transaction ID and having the transaction ID (optionally) generated deterministically.
2 phase commit is an extremely heavy weight pattern and finds far less use than something like the above.