Skip to content

Lab 11 — Concurrency and Locks

Scenario

A slow request may be waiting rather than executing. This lab uses blocking relationships and wait events to distinguish lock delay from query-plan cost.

Run the exercise

Use at least two psql sessions to create and observe a controlled blocking case, then run:

make shell
\i sql/labs/11-concurrency/bad_queries.sql

Investigate

  1. Identify blocked and blocking process IDs.
  2. Inspect transaction state, query text, and wait-event type.
  3. Build the blocking chain rather than focusing only on the final waiter.
  4. Explain how long transactions and application behavior contribute.
  5. Prefer ending the controlled test transaction; do not terminate unrelated sessions.

Diagnostic question

Is latency caused by execution or waiting, and which session at the root of the blocking chain must be addressed?

Previous: Incidents · Next: Maintenance