Help Center/ GaussDB/ API Reference/ APIs (Recommended)/ SQL Throttling/ Modifying a SQL Throttling Task
Updated on 2024-11-07 GMT+08:00

Modifying a SQL Throttling Task

Function

This API is used to modify a SQL throttling task based on the specific scope and type. Before calling this API:

URI

PUT https://{Endpoint}/v3/{project_id}/instances/{instance_id}/limit-task/{task_id}

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Explanation:

Project ID of a tenant in a region.

For details about how to obtain the value, see Obtaining a Project ID.

Restrictions:

None

Value range:

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

Default value:

None

instance_id

Yes

Instance ID.

task_id

Yes

Throttling task ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

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.

X-Language

No

String

Language.

Default value: en-us

Value range:

  • zh-cn
  • en-us
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

start_time

No

String

Task start time. This parameter is mandatory when task_scope is set to SQL.

Value range: two minutes later than or equal to the current time (UTC time).

The format must be yyyy-mm-ddThh:mm:ss+0000.

end_time

No

String

Task end time. This parameter is mandatory when task_scope is set to SQL.

Value range: later than the task start time.

The format must be yyyy-mm-ddThh:mm:ss+0000.

key_words

No

String

Keyword. This parameter is mandatory when limit_type is set to SQL_TYPE.

You can enter 2 to 100 keywords and separate multiple keywords by commas (,). Each keyword can contain 2 to 64 characters and cannot start and end with a space. The specifical characters ("\{}) and null are not allowed.

task_name

No

String

Name of the SQL throttling task. The value can contain up to 100 characters. Only uppercase letters, lowercase letters, underscores (_), digits, and dollar signs ($) are allowed.

parallel_size

No

Integer

Maximum concurrency. The value can be 0 or a positive integer. Value range: [0, 2147483647]

cpu_utilization

No

Integer

CPU usage threshold. The value is an integer ranging from [0, 100).

This parameter is mandatory when limit_type is set to SESSION_ACTIVE_MAX_COUNT.

This parameter and memory_utilization cannot be both set to 0. If you only need one of them for throttling, set the other threshold to 0.

memory_utilization

No

Integer

Memory usage threshold. The value is an integer ranging from [0, 100).

This parameter is mandatory when limit_type is set to SESSION_ACTIVE_MAX_COUNT.

This parameter and cpu_utilization cannot be both set to 0. If you only need one of them for throttling, set the other threshold to 0.

databases

No

String

Databases of the instance. Databases are separated by commas (,).

This parameter is mandatory when limit_type is set to SQL_TYPE.

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

task_id

String

Throttling task ID.

databases

String

Databases of the instance. Databases are separated by commas (,).

task_name

String

Throttling task name.

key_words

String

Keyword. This parameter is returned only when the task type is SQL_TYPE.

parallel_size

Integer

Maximum concurrency.

cpu_utilization

Integer

CPU usage threshold. This parameter is returned with only its integer part retained when the task type is SESSION_ACTIVE_MAX_COUNT.

memory_utilization

Integer

Memory usage threshold. This parameter is returned with only its integer part retained when the task type is SESSION_ACTIVE_MAX_COUNT.

start_time

String

Start time of the throttling task. The format is yyyy-mm-ddThh:mm:ssZ. This parameter is returned when task_scope is set to SQL.

end_time

String

End time of the throttling task. The format is yyyy-mm-ddThh:mm:ssZ. This parameter is returned when task_scope is set to SQL.

rule_name

String

Rule name.

job_id

String

Job ID.

Example Request

  • Modifying a throttling task whose type is SQL_ID
    https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/3d39c18788b54a919bab633874c159dfin14/limit-task/96854ba7-8d50-4a3c-8fd8-210a7390e9d1
    {
      "start_time" : "2024-08-20T06:54:42+0800",
      "end_time" : "2024-08-20T07:54:42+0800",
      "task_name" : "SOLIdLimit",
      "parallel_size" : 10
    }
  • Modifying a throttling task whose type is SQL_TYPE
    https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/3d39c18788b54a919bab633874c159dfin14/limit-task/96854ba7-8d50-4a3c-8fd8-210a7390e9d1
    {
      "start_time" : "2024-08-20T06:54:42+0800",
      "end_time" : "2024-08-20T07:54:42+0800",
      "key_words" : "version,type",
      "task_name" : "KeywordLimit",
      "parallel_size" : 10,
      "databases" : "gaussdb_test3"
    }
  • Modifying a throttling task whose type is SESSION_ACTIVE_MAX_COUNT
    https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/3d39c18788b54a919bab633874c159dfin14/limit-task/96854ba7-8d50-4a3c-8fd8-210a7390e9d1
    {
      "task_name": "ThresholdLimit",
      "parallel_size": 10,
      "cpu_utilization": 20,
      "memory_utilization": 20
    }

Example Response

  • Throttling task whose type is SQL_ID modified.
    {
        "task_id": "bca08a79-8557-42c2-ab73-09a14d178c57",
        "task_name": "SOLIdLimit",
        "parallel_size": 10,
        "start_time": "2024-08-19T22:54:42Z",
        "end_time": "2024-08-19T23:54:42Z",
        "job_id": "d44bbbc3-4465-4079-ac71-d8e7ab0643a4"
    }
  • Throttling task whose type is SQL_TYPE modified.
    {
        "task_id": "ef8575c7-0133-43b4-8ab2-b950b9a6daaf",
        "databases": "gaussdb_test3",
        "task_name": "KeywordLimit",
        "key_words": "type,version",
        "parallel_size": 10,
        "start_time": "2024-08-19T22:54:42Z",
        "end_time": "2024-08-19T23:54:42Z",
        "job_id": "40e2e10f-6f4c-4883-9db7-5422f42187cc"
    }
  • Throttling task whose type is SESSION_ACTIVE_MAX_COUNT modified.
    {
        "task_id": "37b6232c-58ea-4d62-a5b5-54fc215c2115",
        "task_name": "ThresholdLimit",
        "parallel_size": 10,
        "cpu_utilization": 20,
        "memory_utilization": 20,
        "job_id": "0ec7109d-bc8f-41f6-9a78-a70f966739fc"
    }

Status Code

Error Code

For details, see Error Codes.