1.查询激活的执行中的sql,查看有哪些更新update的sql。
select *
from pg_stat_activity
where state = 'active';
2. 查询表中存在的锁
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 lower(b.relname) = 'h5_game';
3. 杀掉死锁进程
select pg_terminate_backend(pid)
from pg_stat_activity
where state = 'active'
and pid != pg_backend_pid()
--and pid = 14172
and pid in (select a.pid
from pg_locks a
join pg_class b on a.relation = b.oid
where lower(b.relname) = 'news_content')
锁模式
/* NoLock is not a lock mode, but a flag value meaning "don't get a lock" */ #define NoLock 0 #define Access