Truncate table hanging with no other running queries

0

Maybe once every other month I get a truncate table command that just hangs and dies. Never on the same table, and when I check for other running queries there are none except the truncate (select * from stv_recents where status<>'Done'). I need to reboot the server to get it to run. How can I identify what is actually locking the table?

bryanam
已提問 3 年前檢視次數 246 次
1 個回答
0
已接受的答案

Here's a few stock queries I use to investigate

select t.relname,pid,mode,granted
from pg_locks l, pg_stat_all_tables t
where l.relation=t.relid order by relation asc;

select distinct(relation) table_id
,xid
,pid
,txn_start
,lock_mode
,trim(nspname) schema_name
,trim(relname) table_name
from svv_transactions
left join pg_class on pg_class.oid = svv_transactions.relation
join pg_namespace on pg_namespace.oid = relnamespace;

You can also use stv_locks;

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南