Creates a task that terminates sessions.

  • This operation is applicable to only ApsaraDB RDS for MySQL instances and PolarDB for MySQL instances.
  • If you use an Alibaba Cloud SDK or a Database Autonomy Service (DAS) SDK to call this API operation, we recommend that you use the latest version of the SDK.
  • If you use an SDK to access DAS, you must set the region ID to cn-shanghai.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesCreateKillInstanceSessionTask

The operation that you want to perform. Set the value to CreateKillInstanceSessionTask.

InstanceIdStringYesrm-2ze8g2am97624****

The ID of the instance.

NodeIdStringNopi-bp1v203xzzh0a****

The ID of the node.

Note The ID of the node is required if you query the sessions of a PolarDB for MySQL instance. If you do not specify a node ID and the KillAllSessions parameter is set to true, the system traverses all nodes of the PolarDB for MySQL instance and terminates the active sessions on each node.
DbUserStringYestestUser

The database account that has the permissions to terminate sessions.

DbUserPasswordStringYestestPassword

The password of the database account.

IgnoredUsersStringNo['db_user1','db_user2']

The account whose sessions do not need to be terminated.

Note The value of the parameter is a JsonArray string. Separate database accounts with commas (,). Example: ['Database account 1','Database account 2'].
KillAllSessionsBooleanYestrue

Specifies whether to terminate all sessions.

  • true: terminates all sessions.
  • false: does not terminate all sessions.
Note If you set this parameter to true, sessions of the accounts that are specified by the IgnoredUsers parameter, sessions of internal O&M accounts of Alibaba Cloud, and Binlog Dump sessions are not terminated.
SessionIdsStringNo[10805639,10805623,10805645,10805553,10805566,10805616]

The IDs of sessions that need to be terminated.

Note The value of this parameter is a JsonArray string. Separate session IDs with commas (,). Example: ['Session ID1','Session ID2']. If the KillAllSessions parameter is set to true, this parameter does not take effect.

Response parameters

ParameterTypeExampleDescription
CodeLong200

The HTTP status code returned.

MessageStringSuccessful

The message that is returned for the request.

Note If the request is successful, Successful is returned. If the request fails, an error message that includes an error code is returned.
DataStringf77d535b45405bd462b21caa3ee8****

The ID of the task that terminated the sessions.

Note If the sessions of a PolarDB for MySQL instance were terminated., the NodeId parameter is left empty, and the KillAllSessions parameter is set to true, the task IDs are returned based on the number of nodes. Example: ["f77d535b45405bd462b21caa3ee8****", "e93ab549abb081eb5dcd5396a29b****"]
RequestIdStringB6D17591-B48B-4D31-9CD6-9B9796B2****

The ID of the request.

SuccessBooleantrue

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.

Examples

Sample requests

http(s)://das.cn-shanghai.aliyuncs.com/?Action=CreateKillInstanceSessionTask
&InstanceId=rm-2ze8g2am97624****
&DbUser=testUser
&DbUserPassword=testPassword
&IgnoredUsers=['db_user1','db_user2']
&KillAllSessions=true
&SessionIds=[10805639,10805623,10805645,10805553,10805566,10805616]
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateKillInstanceSessionTaskResponse>
    <Code>200</Code>
    <Message>Successful</Message>
    <Data>f77d535b45405bd462b21caa3ee8****</Data>
    <RequestId>B6D17591-B48B-4D31-9CD6-9B9796B2****</RequestId>
    <Success>true</Success>
</CreateKillInstanceSessionTaskResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Code" : 200,
  "Message" : "Successful",
  "Data" : "f77d535b45405bd462b21caa3ee8****",
  "RequestId" : "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success" : true
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParamsThe request parameters are invalid.The error message returned because the specified request parameters are invalid.

For a list of error codes, see Service error codes.