killSessions

On this page本页内容

Definition定义

killSessions

The killSessions command kills the specified sessions. killSessions命令将终止指定的会话。If access control is enabled, the command only kills the sessions owned by the user. 如果启用了访问控制,则该命令仅终止用户拥有的会话。[1]

Syntax语法

The command has the following syntax:该命令具有以下语法:

db.runCommand( { killSessions: [ { id : <UUID> }, ... ] } )

The command takes an array of documents that specify the UUID portion of the session id. 该命令接受一组文档,这些文档指定会话id的UUID部分。Specify an empty array [ ] to kill all sessions, or if access control is enabled, all sessions owned by the user. 指定一个空数组[ ]以终止所有会话,或者如果启用了访问控制,则终止用户拥有的所有会话。[1]

To view existing sessions, see $listSessions operation or $listLocalSessions.要查看现有会话,请参阅$listSessions操作或$listLocalSessions

[1](1, 2) The killSessions operation ignores sessions that have transactions in prepared state. killSessions操作忽略事务处于准备状态的会话。See Behavior for details.有关详细信息,请参阅行为

Behavior行为

Session Identification会话标识

MongoDB concatenates each of the specified UUIDs with the hash of the authenticated user credentials to identify the user's sessions to kill. MongoDB将每个指定的UUID与经过身份验证的用户凭据的哈希连接起来,以标识要终止的用户会话。If the user has no session that match, the killSessions has no effect.如果用户没有匹配的会话,则killSessions无效。

In-progress Operations正在进行的操作

Killing a session kills any in-progress operations in the session and closes any open cursors associated with these operations.终止会话将终止会话中正在进行的任何操作,并关闭与这些操作关联的所有打开的游标。

Killed Session Availability已终止会话可用性

The killed session may still be listed as a current session, and future operations may use the killed session. 被终止的会话仍可能被列为当前会话,未来的操作可能会使用被终止会话。To view existing sessions, see $listSessions operation or $listLocalSessions.要查看现有会话,请参阅$listSessions操作或$listLocalSessions

Sessions with Transactions in Prepared State事务处于准备状态的会话

The killSessions operation ignores sessions that have transactions in prepared state. killSessions操作忽略事务处于准备状态的会话。Transactions in prepared state refer to transactions with write operations that span multiple shards whose commit coordinator has completed the "sendingPrepare" action.处于已准备状态的事务是指具有写操作的事务,这些操作跨越多个分片,提交协调器已完成"sendingPrepare"操作

Example示例

The following operation kills the specified session for the user:以下操作将终止用户的指定会话:

db.runCommand( { killSessions: [ { id: UUID("f9b3d8d9-9496-4fff-868f-04a6196fc58a") } ] } )
Tip提示
See also: 参阅:
←  killAllSessionsByPatternrefreshSessions →