对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

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: The fully managed service for MongoDB deployments in the cloud

重要

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

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]

要查看现有会话,请参阅$listSessions操作或$listLocalSessions 。

[1](1, 2) The killSessions operation ignores sessions that have transactions in prepared state. See Behavior 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.

终止会话会终止会话中所有进行中的操作,并关闭与这些操作关联的所有打开的游标。

被终止的会话可能仍会列为当前会话,并且将来的操作可能会使用被终止的会话。 要查看现有会话,请参阅$listSessions操作或$listLocalSessions 。

The killSessions operation ignores sessions that have Transactions 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.

以下操作会终止用户的指定会话:

db.runCommand( { killSessions: [ { id: UUID("f9b3d8d9-9496-4fff-868f-04a6196fc58a") } ] } )