//查询锁表的情况
SELECT A.locktype,A.DATABASE,A.pid,A.mode,b.relname FROM pg_locks A JOIN pg_class b ON A.relation = b.oid;
//杀死进程
select pg_terminate_backend(pid); //pid为进程id号
//用于查询系统进程状态的表
select * from pg_stat_activity;
主要关注waiting 是否等待中,stat 进程状态, query 具体语句
当waiting 为t 的进行需要特别注意,query可以查看到具体语句,然后进行查杀
//用于查询系统进程状态的表
select * from pg_stat_activity;
主要关注waiting 是否等待中,stat 进程状态, query 具体语句
当waiting 为t 的进行需要特别注意,query可以查看到具体语句,然后进行查杀
最终的原因排查为,mq拥堵导致一些流程走不了,代码流程又涉及到更新等操作,产生数据库锁 一直占用着连接的资源 。
/* NoLock is not a lock mode, but a flag value meaning "don't get a lock" */
#define NoLock 0
#define AccessShareLock 1 /* SELECT */
#define RowShareLock 2 /* SELECT FOR UPDATE/FOR SHARE */
#define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */
#define ShareUpdateExclusiveLock 4 /* VACUUM (non-FULL),ANALYZE, CREATE
* INDEX CONCURRENTLY */
#define ShareLock 5 /* CREATE INDEX (WITHOUT CONCURRENTLY) */
#define ShareRowExclusiveLock 6 /* like EXCLUSIVE MODE, but allows ROW
* SHARE */
#define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR
* UPDATE */
#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM
* FULL, and unqualified LOCK TABLE */