killSessions
定义
killSessions
The
killSessions
command kills the specified sessions. If access control is enabled, the command only kills the sessions owned by the user. [1]
语法
该命令具有以下语法:
db.runCommand( { killSessions: [ { id : <UUID> }, ... ] } )
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0、M2、M5 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
命令字段
The command takes an array of documents that specify the UUID portion
of the session id. Specify an empty array [ ]
to kill all sessions,
or if access control is enabled, all sessions owned by the user.
[1]
View Existing Sessions
To view existing sessions, see $listSessions
operation or
$listLocalSessions
.
[1] | (1, 2) The killSessions operation ignores sessions that have
事务 in prepared state. See
行为 for details. |
行为
会话识别
MongoDB concatenates each of the specified UUIDs with the hash of the
authenticated user credentials to identify the user's sessions to kill.
If the user has no session that match, the killSessions
has no effect.
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
.
Sessions with Transactions in Prepared State
The killSessions
operation ignores sessions that have 事务 in
prepared state. Transactions in prepared state refer to transactions
with write operations that span multiple shards whose commit
coordinator has completed the "sendingPrepare" action
.
例子
The following operation kills the specified session for the user:
db.runCommand( { killSessions: [ { id: UUID("f9b3d8d9-9496-4fff-868f-04a6196fc58a") } ] } )
另请参阅: