The PostgreSQL update waiting on a lock
A healthy PostgreSQL database accepts connections, but an application update times out waiting for a row lock.

The scenario
A synthetic inventory update times out even though PostgreSQL is available. Identify the blocking transaction and restore write access without changing the inventory data or disabling the application.
Mission objectives
- Reproduce the lock timeout as the application role.
- Inspect PostgreSQL activity and locks to identify the blocking transaction.
- Release the lab blocker and verify a bounded application update without altering the data.
Lab README
The PostgreSQL update waiting on a lock
The database accepts connections, but the application update times out. Find the blocking transaction and restore access to the synthetic inventory row without changing its data or granting broader privileges.
Before you begin
Use a disposable machine with Bash, Python 3, Docker and Docker Compose.
The lab creates breakfix-dbops-03, an internal Docker network and a named
database volume. It publishes no host ports and creates no cloud resources.
Docker may download PostgreSQL 17. Authentication is intentionally insecure;
never use these settings or this project name for real workloads. Other users
with Docker access can reach the lab database.
Setup refuses existing project resources. Teardown checks container ownership before deleting this lab's containers, network and database volume. The synthetic blocking transaction sleeps for up to one hour.
Investigate
./setup.sh
docker compose -p breakfix-dbops-03 ps
docker compose -p breakfix-dbops-03 exec db psql -X -U lab_admin -d lab
In the lab database, inspect pg_stat_activity, pg_locks and the
inventory table. Compare the blocking session with the application role
lab_writer. Investigate the timeout using a short lock_timeout; do not
change the table or disable the application. This lab's blocker is disposable;
in production, identify the owner and transaction impact before terminating a
session.
After recovery, run ./verify.sh and ./teardown.sh. Verification checks
the original rows and performs a bounded update as lab_writer in a
rolled-back transaction. Teardown deletes the synthetic database volume.
Get the lab
Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.
curl -fsSLO https://devops.download/labs/dbops-03-blocked-transaction.sh less dbops-03-blocked-transaction.sh
bash dbops-03-blocked-transaction.sh
cd labs/dbops-03-blocked-transaction
./setup.shWhen you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.
Need a nudge?
Hint #1
A successful database connection does not mean the requested row is available. Inspect pg_stat_activity and pg_locks.
Hint #2
The lab blocker holds an open transaction. Check its identity before ending it; in production, assess the transaction and coordinate before terminating anything.
Hint #3 · Learning paths on opsbreakfix.com
Solved it?
Continue learning with the paths on opsbreakfix.com.
Continue to opsbreakfix.com ↗