Problem
The wallet transfer process is not atomic.
If the system crashes or an error occurs after debiting Alice but before crediting Bob, the transfer ends in an inconsistent state where money is effectively lost.
This results in partial updates that violate financial integrity.
Points: 40
Steps to Reproduce
- Initiate a transfer from Alice to Bob.
- Allow the debit operation on Alice’s balance to complete.
- Force a crash or simulate an exception before the credit operation executes for Bob.
- Notice:
- Alice’s balance decreases.
- Bob’s balance does not increase.
- The system has lost money due to the incomplete transaction.
Expected Behavior
Transfers must be fully atomic:
- Both operations (debit and credit) should succeed together, or
- Both should be rolled back if any part fails.
To fix this, implement:
- Database transactions (MongoDB sessions / SQL transactions), or
- An equivalent atomic mechanism ensuring transfer operations are grouped and committed as one unit.
No transfer should ever result in partial updates or lost funds.
Submission Guidelines
- Comment on this issue with your proposed solution approach.
- Wait for issue assignment from reviewers.
- Create a PR with clear, descriptive commit messages.
- Reference this issue in your PR description.