Prevent Lost Updates When Two Debits Hit One Checking Account

Last updated: November 29, 2026

Quick Overview

Two services (card authorization and ACH) each read a checking account balance and then write a new balance, and occasionally one debit disappears; explain the anomaly, compare isolation levels and locking options, and implement a fix.

J.P. Morgan
Software Engineering Fundamentals
Software Engineer
J.P. Morgan
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Two services (card authorization and ACH) each read a checking account balance and then write a new balance, and occasionally one debit disappears; explain the anomaly, compare isolation levels and locking options, and implement a fix.

J.P. Morgan onsites for core banking roles often probe transaction isolation through a concrete Chase checking scenario, because a lost update is a real dollar error. The interviewer wants you to name the read-modify-write race, explain why READ COMMITTED does not stop it, and pick between atomic updates, pessimistic row locks and optimistic versioning with reasons.

What the Interviewer Expects
  • Name the lost update anomaly and draw the interleaving
  • Explain which isolation levels prevent it and their costs
  • Offer an atomic conditional UPDATE as the simplest fix
  • Implement optimistic concurrency with a version column and retry
  • Add a CHECK constraint so the database enforces non-negative balance
Key Topics to Cover
transactions
isolation levels
optimistic locking
lost update
SQL
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
  • When is SELECT FOR UPDATE better than optimistic versioning?
  • How do you make the retry safe if the client times out and resends?
  • Why do real banks post debits as ledger entries rather than updating a balance column?
  • What does SERIALIZABLE in PostgreSQL do when it detects a conflict?
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

Account ACC1 has 100.00. Card auth debits 70.00, ACH debits 60.00 at nearly the same moment. Correct result: one succeeds and the other is declined for insufficient funds. Observed: both read 100.00, ...

High-Level Design

This is a lost update: read, compute in application code, write, with nothing tying the write to what was read. READ COMMITTED (the default in PostgreSQL and Oracle) allows it. Options, simplest first...


Submit Your Answer
Markdown supported

Related Questions