0

I have a hung query and cannot terminate it. I have tried the following to retrieve the pid:

SELECT * FROM pg_stat_activity WHERE state = 'active';

I have tried cancelling it using the following, but get

ERROR: canceling statement due to user request SQL state: 57014

SELECT pg_cancel_backend(11392);
SELECT pg_terminate_backend(11392);

Below is the dashboard image and the database is active, but shouldn't the status be 'idle' instead of active?

enter image description here

1 Answer 1

1

You canceled your own statement. To determine the correct process ID, exclude your own session:

SELECT pid, query_start, query
FROM pg_stat_activity
WHERE state = 'active'
  AND pid <> pg_backend_pid();
1
  • I placed a table to be recursively called in the function. There wasn't any other active query running.
    – MJM
    Feb 14 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.