DBOps Observer
← All labs

PostgreSQL connections / Intermediate / 25–40 min

The database with no room to connect

An application cannot connect to PostgreSQL even though the database is running. Investigate connection pressure and restore capacity.

LAB IDdbops-01-postgres-connection-exhaustionTRACK / dbops.observer
Engineer inspecting storage servers and hard drives

The scenario

A small PostgreSQL service is healthy, but new application connections are rejected. Investigate its active sessions and recover reliable application access without changing the stored data.

Mission objectives

  • Reproduce the application connection failure.
  • Inspect PostgreSQL session activity and identify the source of connection pressure.
  • Restore capacity and verify concurrent application queries and the original data.

Lab README

PostgreSQL connection exhaustion

The database process is running, but an application cannot establish a new connection. Investigate the active PostgreSQL sessions and restore capacity without changing the synthetic data.

Before you begin

Use a disposable local environment with Bash, Python 3, Docker and Docker Compose. The first run may download the PostgreSQL 17 Alpine image and needs disk space for the image and a small temporary database.

The lab uses Compose project breakfix-dbops-01, a private Docker network and a Docker volume. It publishes no host ports and does not access a cloud account. Database authentication is intentionally insecure for this isolated exercise; never use it for real data or reuse this Compose project name. Other containers with access to the Docker network or daemon may access the lab database.

Start the incident

Run ./setup.sh from this directory. The script waits for the connection failure to appear. Inspect the services with docker compose -p breakfix-dbops-01 ps and database activity with docker compose -p breakfix-dbops-01 exec db psql -U lab_admin -d lab.

Verify and clean up

After investigating and recovering access, run ./verify.sh. It checks the original synthetic data and simultaneous application connections. Run ./teardown.sh to remove this lab's containers, network and database volume, including all changes made within the exercise. Setup refuses to reuse an existing project. Teardown refuses containers associated with another working directory; do not override those checks.

Local Docker usage may consume compute, network bandwidth and disk space; cloud billing is not involved unless you choose to run Docker on a billable host.

View Markdown source ↗

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-01-postgres-connection-exhaustion.sh
less dbops-01-postgres-connection-exhaustion.sh
bash dbops-01-postgres-connection-exhaustion.sh
cd labs/dbops-01-postgres-connection-exhaustion
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

Compare application connection errors with the database's connection limits and reserved slots.

Hint #2

Inspect session state and application names in PostgreSQL's activity view; consider which client is holding connections.

Hint #3 · Learning paths on opsbreakfix.com

Explore learning paths ↗

Solved it?

Continue learning with the paths on opsbreakfix.com.

Continue to opsbreakfix.com ↗

One ecosystem.
Many perspectives.

Follow the connection from a hands-on lab to the knowledge and tools behind it.