Basic transaction for money transfer

Easy
2 views 23 Jan 2026
Transfer 500 from account 1 to account 2 using a transaction....

Read consistency example

Easy
3 views 23 Jan 2026
Inside one transaction, read the same row twice. Show the basic idea using SELECT statements....

Avoid dirty writes

Easy
2 views 23 Jan 2026
Show that you should lock a row before updating by using SELECT ... FOR UPDATE....

Set isolation level

Easy
2 views 23 Jan 2026
Set transaction isolation level to READ COMMITTED for a transaction....

Handle lost update (pattern)

Easy
2 views 23 Jan 2026
Two sessions update same row. Show a safe pattern using a version column and conditional update....

Detect and prevent phantom reads (concept + SQL)

Medium
4 views 23 Jan 2026
Write a transaction that counts active orders, then inserts a new active order. Mention isolation needed in description and show SERIALIZABLE statement....

Use savepoint in a business transaction

Medium
2 views 23 Jan 2026
While placing an order, keep a savepoint after reserving stock. If payment fails, rollback to savepoint....

Explain deadlock with small example

Medium
2 views 23 Jan 2026
Two transactions lock resources in opposite order. Provide two scripts in sample_solution separated by a pipe symbol....

Row-level locking for order processing

Medium
2 views 23 Jan 2026
When processing an order, lock it so two workers do not process it together. Write a safe SELECT FOR UPDATE pattern....

Atomic decrement with check

Medium
4 views 23 Jan 2026
Decrease Inventory.qty by requested amount only if enough stock. Make it atomic in one statement and run inside a transaction....

Serializable queue pop (advanced)

Hard
2 views 23 Jan 2026
Implement a safe job-queue pop: pick one NEW job, lock it so others can't pick it, mark it IN_PROGRESS, and return the picked job_id. Use FOR UPDATE SKIP LOCKED if available....

Double-spend prevention in wallet

Hard
4 views 23 Jan 2026
Wallet(user_id, balance). Two payments at same time should not allow negative balance. Write a safe transaction with check....

Snapshot reporting without blocking writes

Hard
3 views 23 Jan 2026
You need a consistent report while inserts keep happening in parallel. Start a transaction in REPEATABLE READ and run your report query inside it....

Detect and handle write skew (concept)

Hard
2 views 23 Jan 2026
Two doctors on call table. Each transaction sees at least one on call and turns itself off, resulting none on call. Use SERIALIZABLE to prevent....

Lock timeout and safe retry idea

Hard
3 views 23 Jan 2026
While processing orders, sometimes you get stuck waiting on locks. Set a short lock timeout, pick one NEW order with a row lock, update it to PROCESSING, then commit....