更新时间:2024-02-07 GMT+08:00
分享

PGXC_LOCKWAIT_DETAIL

PGXC_LOCKWAIT_DETAIL视图显示集群中每个节点中锁等待链详细信息。如果节点中有多级的锁等待关系,会依次将整个锁等待链按照等待顺序显示出来。

该视图仅8.1.3.200及以上集群版本支持。

表1 PGXC_LOCKWAIT_DETAIL字段

名称

类型

描述

level

integer

锁等待链中的层级,以1开始,每显示一层等待关系level会加1。

node_name

name

节点名称,对应pgxc_node表中的node_name列。

lock_wait_hierarchy

text

锁等待链,以节点名称:进程号->等待进程号->等待进程号->...。

lock_type

text

被锁定对象的类型。

database

oid

被锁定对象所在数据库的oid。

relation

oid

被锁定对象关系的oid。

page

integer

关系内部的页面编号。

tuple

smallint

页面的行编号。

virtual_xid

text

事务的虚拟id。

transaction_id

xid

事务id。

class_id

oid

包含该对象的系统表的oid。

obj_id

oid

对象在其系统表内的oid。

obj_subid

smallint

对于表的列字段编号。

virtual_transaction

text

持有此锁或者在等待此锁的事务的虚拟id。

pid

bigint

持有此锁或者等待此锁的线程号。

mode

text

锁级别。

granted

boolean

是否持有锁。

fastpath

boolean

是否通过fastpath机制获得锁。

wait_for_pid

bigint

锁冲突线程的线程号。

conflict_mode

text

锁冲突线程持有的冲突锁级别。

query_id

bigint

查询语句的id。

query

text

查询语句。

application_name

text

连接到该后端的应用名。

backend_start

timestamp with time zone

后端进程启动时间,即客户端连接服务器的时间。

xact_start

timestamp with time zone

当前事务的启动时间。

query_start

timestamp with time zone

开始当前活跃查询的时间。

state

text

后端当前总体状态。

应用实例

  1. 连接dn节点,开启一个事务,执行查询:

    1
    begin;select * from t1;
    

  2. 再开启一个窗口连接cn,对表t1执行truncate:

    1
    truncate t1;
    

    此时truncate会被阻塞。

  3. 另外再开启一个窗口连接cn,执行select * from pgxc_lockwait_detail;

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    SELECT * FROM PGXC_LOCKWAIT_DETAIL;
    level | node_name |             lock_wait_hierarchy              | lock_type | database |  relation  | page | tuple | virtual_xid | transaction_id | class_id | obj_id | obj_subid | virtual_transaction |       p
    id       |        mode         | granted | fastpath |  wait_for_pid   |  conflict_mode  |     query_id      |                     query                      | application_name |         backend_start         |
    xact_start           |          query_start          |        state
    -------+-----------+----------------------------------------------+-----------+----------+------------+------+-------+-------------+----------------+----------+--------+-----------+---------------------+--------
    ---------+---------------------+---------+----------+-----------------+-----------------+-------------------+------------------------------------------------+------------------+-------------------------------+--
    -----------------------------+-------------------------------+---------------------
    1 | datanode1 | datanode1:140378619314976                    | relation  |    16049 | 2147484411 |      |       |             |         673638 |          |        |           | 19/297              | 1403786
    19314976 | AccessExclusiveLock | f       | f        | 140378619263840 | AccessShareLock | 73183493945504391 | TRUNCATE t1                     | coordinator1     | 2023-03-13 12:13:52.530602+08 | 2
    023-03-13 14:52:16.1456+08   | 2023-03-13 14:52:16.148693+08 | active
    2 | datanode1 | datanode1:140378619314976 -> 140378619263840 | relation  |    16049 | 2147484411 |      |       |             |                |          |        |           | 23/16067            | 1403786
    19263840 | AccessShareLock     | t       | f        |                 |                 |                 0 | begin;select * from t1; | gsql             | 2023-03-13 14:19:26.325602+08 | 2
    023-03-13 14:52:12.042741+08 | 2023-03-13 14:52:12.042741+08 | idle in transaction
    (2 rows)
    

分享:

    相关文档

    相关产品