PostgreSQL中關閉死結進程的方法,postgresql進程

來源:互聯網
上載者:User

PostgreSQL中關閉死結進程的方法,postgresql進程

由於使用的PostgreSQL資料庫,沒有資料。只好進行Google。

最終在一個英文論壇中發現瞭解決方法。

如下:

1.檢索出死結進程的ID

複製代碼 代碼如下:
SELECT * FROM pg_stat_activity WHERE datname='死結的資料庫ID ';

檢索出來的欄位中,【wating 】欄位,資料為t的那條,就是死結的進程。找到對應的【procpid 】列的值。

2.將進程殺掉

複製代碼 代碼如下:
SELECT pg_cancel_backend('死結那條資料的procpid值 ');

結果:運行完後,再次更新這個表,sql順利執行。
 
ps:尋找了一下資料庫自己的函數列表,發現pg_terminate_backend()函數也可以殺掉進程。

官網上給出的內容:http://www.postgresql.org/docs/9.0/static/functions-admin.html

相關文章

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.