Method to close a deadlock process in PostgreSQL

  • 2020-05-06 11:54:51
  • OfStack

Due to the use of PostgreSQL database, no data is available. I have to do Google.

The solution was found in an English language forum.

As follows:

1. Retrieve ID

of the deadlock process


SELECT * FROM pg_stat_activity WHERE datname=' Deadlocked database ID ';

In the retrieved field, the [wating] field, with data of t, is the deadlock process. Find the value of the corresponding [procpid] column.

2. Kill the process


SELECT pg_cancel_backend(' That data is deadlocked procpid value ');

Result: after running, update the table again, sql executed successfully.
 
ps: a look at the database's own list of functions shows that the pg_terminate_backend() function can also kill processes.

Website content is given: http: / / www postgresql. org docs / 9.0 / static functions - admin. html


Related articles: