A migration stops producing output while the server remains responsive. Adding resources may not be the answer: the session could be waiting for a lock held by another transaction. The first objective is to identify the wait and its owner, not terminate processes at random.

PostgreSQL documents lock modes and monitoring views. This operational explainer was checked on November 9, 2026. It does not describe a newly discovered vulnerability.

Observe without changing the database

With an authorised diagnostic account, the following query provides an initial view. It reads session state and blocker identifiers; it does not terminate any transaction.

SELECT pid, application_name, state,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids
FROM pg_stat_activity
WHERE datname = current_database()
  AND pid <> pg_backend_pid();

Visibility depends on account privileges. Interpret the information functions alongside the views. An “active” session is not necessarily consuming CPU; inspect its wait event as well.

Our recommendation is to record the time and relevant application without routinely copying SQL text into a public channel. Query text may contain information the investigation does not require you to disclose.

Find the owner of the blocking work

A chain of blockers may lead to an operation different from the original migration. Establish who started it, whether it can finish normally and what work it protects.

Before interrupting anything, identify the business impact: an import, payment processing, a schema change or maintenance. Choose an intervention with the service owner rather than only with the person watching the blocked terminal.

Keep the observation and the intervention separate in your notes. A blocker found at one instant may have completed by the time a decision is made.

Interpret the snapshot cautiously

Suppose the migration session reports a lock wait and a list containing another session identifier. That is a lead to investigate, not permission to close the other session immediately. Take another observation after a reasonable interval to establish whether it persists, and relate the result to application logs.

An empty list means this function identifies no lock blocker at that instant. It does not prove that the query is fast or that disk and network activity are healthy. If the symptom disappears between observations, retain the timestamps to understand which operation completed.

The documentation also notes that a zero identifier can represent a blocking prepared transaction. Do not look for a process named “0” to terminate: have someone familiar with the transaction review it. Avoid polling every session intensively too. This initial diagnostic is not a recommendation for extremely high-frequency monitoring.

Distinguish lock wait from total execution time

The client-parameter documentation distinguishes lock_timeout from statement_timeout. The former bounds waits to acquire locks; the latter concerns a statement's duration.

We recommend considering limits for the migration session instead of suddenly imposing a global setting. Test the failure path: how does the tool report interruption, roll back its transaction and support another attempt? A timeout without a recovery procedure merely relocates the problem.

Make recovery an explicit decision

Before rerunning the tool, verify which step actually took effect. Our advice is to compare its migration history, the observed schema and the previous operation's outcome. Do not manually edit the migration registry merely to hide a failure you have not explained.

Define an exit criterion: the expected schema exists, the application can perform its normal read and write workflow, and there is no new abnormal wait. Returning to a command prompt alone does not establish those three things. Verification should be proportionate to the service and prepared with its owner.

Reduce surprises before the next migration

Rehearse against a representative environment. Measure duration, concurrent access and expected locks. An empty database does not necessarily resemble a continuously used service.

Keep a return procedure and a way to verify the schema. Do not assume a retry button is always harmless, particularly when a tool combines several steps outside one transaction.

For slowness without an identified lock wait, our EXPLAIN and BUFFERS article covers a different investigation. Plan optimisation and resolving blocking are separate questions worth keeping distinct.

Cover visual: generated editorial illustration, not an official screenshot.