Blog: notes on backend, data and AI
Notes on backend engineering, data and building products with AI.
November 25, 2026 · 4 min read
Deadlocks in MySQL: find them, prevent them, retry them
A deadlock is two transactions waiting for each other. InnoDB breaks it by rolling one back, so your code must retry. Here is how to read the report and design the cause away.
mysqlinnodblocking
November 25, 2026 · 4 min read
InnoDB locks: record, gap and next-key locks
InnoDB locks index entries, not abstract rows. Learn what record, gap, next-key and intention locks protect, and why a query without a usable index can lock far more than you expect.
mysqlinnodblocking
November 25, 2026 · 4 min read
Hot rows: when one balance becomes the bottleneck
A merchant wallet that receives hundreds of payments per second makes every transaction queue on the same row lock. Adding connections does not help. Splitting the row or batching the updates does.
mysqlperformancelocking
November 25, 2026 · 4 min read
Safe transfers and double-spend prevention in one database
A correct transfer is one short transaction: record it once, lock the wallets in a fixed order, check and subtract atomically, write balanced ledger entries and commit.
paymentstransactionslocking