The Phantom Read
#data-eng-critical — CFO dashboard mismatch
Finance: Total Revenue widget = $10,000. Transaction table sums to $10,050. Background billing inserted row 101 between SUM() and SELECT *.
The trap: default READ COMMITTED — each query gets its own snapshot. Phantom read between sequential queries.
Your task
Fix `getDashboardData()` in `dashboard_server.js`: wrap both queries in an explicit `REPEATABLE READ` transaction so they share one snapshot.
Book: transactions = safe · Prod: dashboard numbers don't match the CSV.
Skills you'll prove
Interview Tip
When asked about database isolation levels or phantom reads, say: "Isolation levels dictate how concurrent transactions interact. The default READ COMMITTED prevents dirty reads, but it allows phantom reads—where a row inserted between two queries in the same transaction appears in the second but not the first. This causes dashboard mismatches. I solve this by explicitly setting the isolation level to REPEATABLE READ for read-heavy analytical queries. This forces the database to take a snapshot at the start of the transaction, ensuring all queries within that transaction see the exact same reality, regardless of concurrent writes."