Updated on 2023-10-23 GMT+08:00

PGXC_THREAD_WAIT_STATUS

In PGXC_THREAD_WAIT_STATUS, you can see all the call layer hierarchy relationship between threads of the SQL statements on all the nodes in a cluster, and the waiting status of the block for each thread, so that you can easily locate the causes of process response failures and similar phenomena.

The definitions of PGXC_THREAD_WAIT_STATUS view and PG_THREAD_WAIT_STATUS view are the same, because the essence of the PGXC_THREAD_WAIT_STATUS view is the query summary of the PG_THREAD_WAIT_STATUS view on each node in the cluster.

Table 1 PGXC_THREAD_WAIT_STATUS columns

Name

Type

Description

node_name

text

Current node name

db_name

text

Database name

thread_name

text

Thread name

query_id

bigint

Query ID. It is equivalent to debug_query_id.

tid

bigint

Thread ID of the current thread

sessionid

bigint

Session ID

lwtid

integer

Lightweight thread ID of the current thread

psessionid

bigint

Parent session ID

tlevel

integer

Level of the streaming thread

smpid

integer

Concurrent thread ID

wait_status

text

Detailed information about the waiting status of the current thread

wait_event

text

Event that the current thread is waiting for. For details, see Table 2.

locktag

text

Information about the lock that the current thread is waiting for

lockmode

text

Lock mode that the current thread is waiting to obtain

block_sessionid

bigint

ID of the session that blocks the current thread from obtaining the lock

global_sessionid

text

Global session ID

Example:

If you run a statement on coordinator1 and no response is returned after a long period of time, establish another connection to coordinator1 to check the thread status on it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
openGauss=# select * from pg_thread_wait_status where query_id > 0;
  node_name   | db_name  | thread_name  | query_id |       tid       | lwtid | ptid  | tlevel | smpid |     wait_status   |   wait_event   
--------------+----------+--------------+----------+-----------------+-------+-------+--------+-------+----------------------
 coordinator1 | postgres | gsql         | 20971544 | 140274089064208 | 22579 |       |      0 |     0 | wait node: datanode4 |
(1 rows)
openGauss=# select * from pgxc_thread_wait_status where query_id > 0;
  node_name   | db_name  | thread_name  |     query_id      |      tid       |   sessionid    | lwtid  | psessionid | tlevel | smpid | wait_status | wait_event
--------------+----------+--------------+-------------------+----------------+----------------+--------+------------+--------+-------+-------------+------------
 coordinator1 | postgres | gsql         | 77687093572155050 | 47212704827136 | 47212704827136 |  63191 |            |      0 |     0 | none        |
 coordinator2 | postgres | coordinator1 | 77687093572155050 | 47403117319936 | 47403117319936 | 159322 |            |      0 |     0 | none        |
 data_node1   | postgres | coordinator1 | 77687093572155050 | 47723869374208 | 47723869374208 | 159320 |            |      0 |     0 | none        |
 data_node2   | postgres | coordinator1 | 77687093572155050 | 47852867290880 | 47852867290880 | 159321 |            |      0 |     0 | none        |
(4 rows)