# 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.
