1、查看表是否有锁:
select a.locktype,a.database,a.pid,a.mode,a.relation,b.relname from pg_locks a join pg_class b on a.relation = b.oid where upper(b.relname) = 'TABLE_NAME';
select usename,current_query,query_start,procpid,client_addr from pg_stat_activity where procpid = 12345;
SELECT pg_cancel_backend(pid of the postgres process);解决这种情况最好是确定好原因,保证数据安全的情况下,将锁移除。