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

PGXC_WAIT_DETAIL

PGXC_WAIT_DETAIL视图显示集群中所有节点SQL的详细等待链信息。该视图仅8.1.3.200及以上集群版本支持。

表1 PGXC_WAIT_DETAIL字段

名称

类型

描述

level

integer

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

lock_wait_hierarchy

text

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

node_name

text

节点名称。

db_name

text

database名称。

thread_name

text

线程名称。

query_id

bigint

查询语句的id。

tid

bigint

当前线程的线程号。

lwtid

integer

当前线程的轻量级线程号。

ptid

integer

streaming线程的父线程。

tlevel

integer

streaming线程的层级。

smpid

integer

并行线程的ID。

wait_status

text

当前线程的等待状态。

wait_event

text

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

exec_cn

boolean

是否执行sql语句的cn节点。

wait_node

text

锁级别。

query

text

查询语句。

application_name

text

连接到该后端的应用名。

backend_start

timestamp with time zone

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

xact_start

timestamp with time zone

当前事务的启动时间。

query_start

timestamp with time zone

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

waiting

boolean

是否正处于等待状态。

state

text

后端当前总体状态。

应用实例

  1. 连接CN节点,开启一个事务,执行update操作:

    1
    begin;update td set c2=6 where c1=1;
    

  2. 重开一个窗口连接CN节点,开启另一个事务,执行update操作(注意不要并发更新同一条记录):

    1
    begin;update td set c2=6 where c1=7;
    

    此时update操作会被阻塞。

  3. 再开一个窗口连接CN节点,创建一个索引:

    1
    create index c2_key on td(c2);
    

  4. 执行select * from pgxc_wait_detail;

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    SELECT * FROM PGXC_WAIT_DETAIL;
    level |                lock_wait_hierarchy                 | node_name | db_name  | thread_name |     query_id      |       tid       | lwtid  | ptid | tlevel | sm
    pid | wait_status  | wait_event | exec_cn | wait_node |                 query                  | application_name |         backend_start         |          xact_st
    art           |          query_start          | waiting | state
    -------+----------------------------------------------------+-----------+----------+-------------+-------------------+-----------------+--------+------+--------+---
    ----+--------------+------------+---------+-----------+----------------------------------------+------------------+-------------------------------+-----------------
    --------------+-------------------------------+---------+--------
    1 | cn_5001:139870843444360                            | cn_5001   | postgres | workload    | 73183493945299462 | 139870843444360 | 578531 |      |      0 |
    0 | wait node    |            | t       |           | WLM fetch collect info from data nodes | workload         | 2023-03-13 13:56:56.611486+08 | 2023-03-14 11:54
    :33.562808+08 | 2023-03-13 13:57:00.262736+08 | t       | active
    1 | cn_5001:139870843654544                            | cn_5001   | postgres | gsql        | 73183493945299204 | 139870843654544 | 722259 |      |      0 |
    0 | wait node    |            | t       |           | update td set c2=6 where c1=1;         | gsql             | 2023-03-14 11:52:05.176588+08 | 2023-03-14 11:52
    :19.054727+08 | 2023-03-14 11:53:58.114794+08 | t       | active
    1 | cn_5001:139870843655296                            | cn_5001   | postgres | gsql        | 73183493945299218 | 139870843655296 | 722301 |      |      0 |
    0 | wait node    |            | t       |           | update td set c2=6 where c1=7;         | gsql             | 2023-03-14 11:52:08.084265+08 | 2023-03-14 11:52
    :42.978132+08 | 2023-03-14 11:53:59.459575+08 | t       | active
    1 | cn_5001:139870843656424                            | cn_5001   | postgres | gsql        | 73183493945299223 | 139870843656424 | 722344 |      |      0 |
    0 | acquire lock | relation   | t       |           | create index c2_key on td(c2);          | gsql             | 2023-03-14 11:52:10.967028+08 | 2023-03-14 11:52
    :53.463227+08 | 2023-03-14 11:54:00.25203+08  | t       | active
    2 | cn_5001:139870843656424 -> cn_5001:139870843655296 | cn_5001   | postgres | gsql        | 73183493945299218 | 139870843655296 | 722344 |      |        |
    |              |            | f       |           | update td set c2=6 where c1=7;         | gsql             | 2023-03-14 11:52:08.084265+08 | 2023-03-14 11:52
    :42.978132+08 | 2023-03-14 11:53:59.459575+08 | t       | active
    (5 rows)
    

分享:

    相关文档

    相关产品