Prevent Lost Updates When Concurrent Transfers Touch One Account Balance

Last updated: November 29, 2026

Quick Overview

Two background workers process transfers between business accounts and sometimes update the same balance at the same time, causing lost updates and occasional deadlocks. Explain the race and implement a transfer function that is correct under concurrency and cannot deadlock.

Intuit
Software Engineering Fundamentals
Software Engineer
Intuit
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Two background workers process transfers between business accounts and sometimes update the same balance at the same time, causing lost updates and occasional deadlocks. Explain the race and implement a transfer function that is correct under concurrency and cannot deadlock.

Money movement in QuickBooks Checking and Intuit's payments platform requires balances that never go wrong under concurrency. The interviewer is checking that you can name the read-modify-write race, use locking correctly, avoid deadlock with a global lock order, and map the same ideas to database transactions.

What the Interviewer Expects
  • Explain the lost update race in a read-modify-write sequence
  • Hold a lock across the balance check and the debit, not just the write
  • Prevent deadlock by acquiring locks in a consistent global order
  • Translate the solution to the database: SELECT FOR UPDATE ordered by id, or conditional updates
  • Describe how to test concurrency bugs
Key Topics to Cover
race conditions
locking
deadlock avoidance
transactions
isolation levels
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you do this with a single SQL statement and no explicit row locks?
  • What isolation level would you choose and what anomalies does each allow here?
  • How would you scale when one account (a platform payout account) is very hot?
  • How would an append-only ledger design change the locking story?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

transfer(src, dst, cents) moves money atomically: the source must have enough funds at the moment of debit, the total across accounts is conserved, and no two transfers can deadlock. Many threads ca...

High-Level Design

The bug: worker 1 reads A = 100, worker 2 reads A = 100, both subtract 80 and write 20, so the account paid out 160 from 100. The fix is mutual exclusion over the read, check and write of both account...


Submit Your Answer
Markdown supported

Related Questions