How to turn off the deadlock process in PostgreSQL _postgresql

Source: Internet
Author: User
Tags postgresql

Due to the use of the PostgreSQL database, there is no data. Had to do Google.

Finally found a solution in an English forum.

As follows:

1. Retrieves the ID of the deadlock process

Copy Code code as follows:

SELECT * from pg_stat_activity WHERE datname= ' deadlock database ID ';

In the retrieved field, the "wating" field, the one with the data T, is the deadlock process. Find the value of the corresponding "Procpid" column.

2. Kill the Process

Copy Code code as follows:

SELECT pg_cancel_backend (' procpid value of the deadlock data ');

Results: After the run, update the table again, the SQL executes smoothly.

PS: Look up the database of its own list of functions, found that the pg_terminate_backend () function can also kill the process.

The content that the official net gives: http://www.postgresql.org/docs/9.0/static/functions-admin.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.