zoukankan      html  css  js  c++  java
  • GreenPlum 锁表以及解除锁定

    最近遇到truncate表,无法清理的情况,在master节点查看加锁情况,并未加锁
    这种情况极有可能是segment节点相关表加了锁,所以遇到这种情况除了排查master节点的锁,所有的segment也要查看锁的持有情况,然后根据情况,进行处理。

    master节点:
    查看segment锁情况
    select gp_execution_dbid(), pid, relation::regclass, locktype, mode, granted 
    from gp_dist_random('pg_locks');
    查看具体什么语句持有的锁
    select gp_execution_dbid() dbid,procpid,current_query
    from gp_dist_random('pg_stat_activity')  
    where procpid in  
    (select pid from gp_dist_random('pg_locks') where locktype='relation' and mode='ExclusiveLock');
    通过以上语句大概定位到持有锁的segment
     
    segment节点:
    根据实际情况进行处理
    1.连接相关segment,xxxx替换为实际segment节点的ip,端口,库名
    PGOPTIONS="-c gp_session_role=utility" psql -h xxxxxxxxx -p xxxx -d  xxxxx
    2.在segment查询相关锁情况
    SELECT
    w.current_query as waiting_query,
    w.procpid as w_pid,
    w.usename as w_user,
    l.current_query as locking_query,
    l.procpid as l_pid,
    l.usename as l_user,
    t.schemaname || '.' || t.relname as tablename
    from pg_stat_activity w
    join pg_locks l1 on w.procpid = l1.pid and not l1.granted
    join pg_locks l2 on l1.relation = l2.relation and l2.granted
    join pg_stat_activity l on l2.pid = l.procpid
    join pg_stat_user_tables t on l1.relation = t.relid
    where w.waiting;
    3.处理持有锁的pid
    select pg_terminate_backend('procpid');
    ---------------------
    --GP查看锁
    SELECT pid,rolname, rsqname, granted,
    current_query, datname
    FROM pg_roles, gp_toolkit.gp_resqueue_status, pg_locks, pg_stat_activity
    WHERE pg_roles.rolresqueue=pg_locks.objid
    AND pg_locks.objid=gp_toolkit.gp_resqueue_status.queueid
    AND pg_stat_activity.procpid=pg_locks.pid;
     
    --GP解除锁定
    pg_cancel_backend(#pid)

    原文:
    https://blog.csdn.net/dazuiba008/article/details/77878465
    https://blog.csdn.net/housen1987/article/details/84295256
  • 相关阅读:
    vue之v-on
    垂直居中下
    垂直居中上
    vue之v-for
    vue之v-if和v-show
    vue之v-model
    vue之v-bind
    数学---目录
    【数学】证明题
    【计算机网络】应用层
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/11126053.html
Copyright © 2011-2022 走看看