user has a balance of 10 dollars.
What if they send 2 requests to withdraw their balance at the same time?
As the server would process 2 requests, it would see the balance to be 10$ at the time of each request, right?
So it would allow both requests to go through and append 2 records, making the balance -10$
What DBMS are you using?
You will have to determine an order to those requests and execute them one after the other in isolation. Meaning in your case, one of the requests must fail
Обсуждают сегодня