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
asked 3 years ago236 views
1 Answer
0
Accepted Answer

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;

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions