EncryptCodecencryptcodec
Simulations/Race Condition

Race Condition

Intermediate

Fire 5 parallel transfer requests at $100 from a $100 account. Without a database transaction lock, all reads happen before any write — turning $100 into -$400.

Progress:
1
Trigger the Race Condition
2
Fix with DB Transaction
⚡ Bank Account
Current Balance
$100
Starting balance ($)
Transfer amount per request ($)
Parallel requests: 5
🛡 Server Protection
Database log
Waiting for requests…

Challenges

1
Trigger the Race Condition
With $100 balance, transfer $100 using 5 parallel requests. Watch the account go negative.
hints
2
Fix with DB Transaction
Enable 'DB Transaction'. Fire the same 5 requests — now only one succeeds.
hints
How to fix Race Conditions
SELECT FOR UPDATE, optimistic locking, idempotency keys

Frequently Asked Questions