CategoriesUncategorized

Fix PostGreSQL Database Hung During Drop or Alter Tables

You may find yourself in a situation where Postgres decides to stop responding after an Alter or Drop command was given in PGAdmin. This can be corrected by using the following commands below.

Shell into Postgres:

psql

Select data from the pg_stat_activity table.

SELECT
  pid,
  now() - pg_stat_activity.query_start AS duration,
  query,
  state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';

Kill the zombie process after getting the PID exit Postgres and run:

sudo kill -9 <ProcessID>

https://medium.com/little-programming-joys/finding-and-killing-long-running-queries-on-postgres-7c4f0449e86d

Leave a Reply

Your email address will not be published. Required fields are marked *