0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgreSQLのロック解除

Posted at

DataSpider開発中で、スクリプト実行途中にトランザクションをコミットする前にエラーが発生したりして、PostgreSQLがロックされることが発生して、解決方法を調べてみました、下記の方法で解決できました。

  1. SQLで自分のプロセスIDを確認する。
      SELECT l.pid, l.locktype, l.mode, c.relname, d.datname
      FROM pg_locks l
    LEFT JOIN pg_class c ON l.relation = c.relfilenode
    LEFT JOIN pg_database d ON l.database = d.oid
      ORDER BY l.pid;
  2. SQLでプロセスを終了する
     SELECT pg_terminate_backend(手順1で確認したプロセスID)
      ※pg_cancel_backendは効きませんでしたが、pg_terminate_backendでプロセス終了できました。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?