Updated on 2025-10-20 GMT+08:00

Querying Wait Events

Function

This API is used to query wait events on a database instance node. Before calling this API:

Constraints

This API is only available for nodes with CNs or DNs (primary or standby DNs) deployed.

Debugging

You can debug this API in API Explorer.

URI

POST /v3/{project_id}/instances/{instance_id}/wait-event-list

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

String

Definition

Instance ID, which uniquely identifies an instance.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

After the request is processed, the value of X-Subject-Token in the message header is the token value.

Constraints

N/A

Range

N/A

Default Value

N/A

X-Language

No

String

Definition

Language.

Constraints

N/A

Range

  • zh-cn
  • en-us

Default Value

en-us

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

node_id

Yes

String

Definition

Node ID. This parameter is available only for nodes with CNs or DNs (primary or standby DNs) deployed.

Constraints

N/A

Range

N/A

Default Value

N/A

system

No

Boolean

Definition

Whether to query data of system users.

Constraints

N/A

Range

N/A

Default Value

false

offset

No

Integer

Definition

Index offset. The query starts from the next piece of data indexed by this parameter.

Constraints

The value must be a non-negative integer.

Range

N/A

Default Value

0: The query starts from the first data record.

limit

No

Integer

Definition

Number of records returned by a query.

Constraints

The value cannot be negative.

Range

[1,100]

Default Value

10

order_fields

No

List<List<String>>

Definition

Sorting fields.

Internally represented as List<String>, where the first element specifies the field to sort by, and the second element indicates the sort order.

Constraints

N/A

wait_event_query_info

No

Object

Definition

Filtering conditions for obtaining wait events.

For details, see Table 4.

Constraints

N/A

Table 4 Parameter description of the WaitEventQueryInfo field

Parameter

Mandatory

Type

Description

database_name

No

String

Definition

Database name.

Constraints

N/A

Range

N/A

Default Value

N/A

user_name

No

String

Definition

Username.

Constraints

N/A

Range

N/A

Default Value

N/A

waiting

No

String

Definition

Whether it is in the waiting state.

Constraints

N/A

Range

  • t: yes
  • f: no

Default Value

N/A

session_id

No

String

Definition

Session ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Table 5 Response body parameters

Parameter

Type

Description

total

Integer

Definition

Total number of wait events.

Range

N/A

rows

Array of objects

Definition

Wait events of the database instance. For details, see Table 6.

Table 6 Parameter description of the WaitEvent field

Parameter

Type

Description

session_id

String

Definition

Session ID.

Range

N/A

pid

String

Definition

Thread ID.

Range

N/A

wait_event

String

Definition

Wait event.

For details, see the wait_event field in "Developer Guide" > "System Catalogs and System Views" > "System Views" > "Other System Views" > "PG_THREAD_WAIT_STATUS".

Range

N/A

wait_status

String

Definition

Wait status.

For details, see the wait_status field in "Developer Guide" > "System Catalogs and System Views" > "System Views" > "Other System Views" > "PG_THREAD_WAIT_STATUS".

Range

N/A

database_name

String

Definition

Database.

Range

N/A

user_name

String

Definition

Username.

Range

N/A

client_addr

String

Definition

Client address.

Range

N/A

client_port

String

Definition

TCP port number used by a client to communicate with the backend.

Range

N/A

session_time

String

Definition

Session duration, in seconds.

Range

N/A

xact_start

String

Definition

Session start time.

Range

N/A

transaction_time

String

Definition

Transaction duration, in seconds.

Range

N/A

query_start

String

Definition

Query start time.

Range

N/A

state_change

String

Definition

Time when state was last changed.

Range

N/A

query_time

String

Definition

Query duration, in seconds.

Range

N/A

backend_start

String

Definition

Session start time.

Range

N/A

waiting

String

Definition

Whether to wait for a lock.

Range

  • t: yes
  • f: no

lockmode

String

Definition

Lock mode (awaiting acquisition).

Range

N/A

block_sessionid

String

Definition

ID of a blocked session.

Range

N/A

block_count

String

Definition

Number of blocked sessions.

Range

N/A

unique_sql_id

String

Definition

Normalized SQL ID.

Range

N/A

query_id

String

Definition

Query ID.

Range

N/A

query

String

Definition

SQL text.

Range

N/A

current_xid

String

Definition

Current transaction ID.

Range

N/A

top_xid

String

Definition

Top-level transaction ID.

Range

N/A

xlog_quantity

String

Definition

Amount of Xlogs currently used by a transaction, in bytes.

Range

N/A

state

String

Definition

Overall state of the session.

Range

  • active: The backend is executing a query.
  • idle: The backend is waiting for a new client command.
  • idle in transaction: The backend is in a transaction, but there is no statement being executed in the transaction.
  • fastpath function call: The backend is executing a fast-path function.
  • disabled: This state is displayed if track_activities is disabled in the backend.

application_name

String

Definition

Application name.

Range

N/A

connection_info

String

Definition

Connection information.

Range

N/A

Example Request

POST https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/cc6fd964d93f4003851dfc29d57d30a5in14/wait-event-list
{
    "node_id": "1fafb3b79c4b41cdb2f8ecd90a80ba5eno14",
    "limit": 1,
    "offset": 10,
    "order_fields": [["query_start", "ASC"]],
    "wait_event_query_info": {
        "database_name": "postgres"
    }
}

Example Response

{
    "total": 1,
    "rows": [
        {
            "session_id": "3377",
            "database_name": "postgres",
            "user_name": "root",
            "unique_sql_id": "3545025713",
            "query_id": "1949495688698202784",
            "pid": "139646718113344",
            "client_addr": "127.0.0.1",
            "client_port": "50856",
            "state": "active",
            "query": "select pg_sleep(300);",
            "application_name": "gsql",
            "wait_event": "wait gs_sleep",
            "wait_status": "wait gs_sleep",
            "session_time": "76",
            "xact_start": "2024-12-21 14:29:38.360946+08",
            "transaction_time": "73",
            "query_start": "2024-12-21 14:29:38.360946+08",
            "state_change": "2024-12-21 14:29:38.360956+08",
            "query_time": "73934470",
            "backend_start": "2024-12-21 14:29:35.728347+08",
            "waiting": "f",
            "lockmode": "",
            "block_sessionid": "",
            "block_count": "",
            "current_xid": "0",
            "top_xid": "0",
            "xlog_quantity": "0",
            "connection_info": "{\"driver_name\":\"libpq\",\"driver_version\":\"(GaussDB Kernel 505.2.1 build 22cc96d0) compiled at 2024-11-27 02:07:13 commit 10063 last mr 20829 release\"}"
        }
    ]
}

Status Codes

Error Codes

For details, see Error Codes.