Definição
killSessionsThe
killSessionscommand kills the specified sessions. If access control is enabled, the command only kills the sessions owned by the user. [1]
Sintaxe
O comando tem a seguinte sintaxe:
db.runCommand( { killSessions: [ { id : <UUID> }, ... ] } )
Compatibilidade
Esse comando está disponível em implantações hospedadas nos seguintes ambientes:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Importante
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB
MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB
Campos de comando
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]
Ver sessões existentes
Para visualizar sessões existentes, consulte operação $listSessions ou $listLocalSessions.
| [1] | (1, 2) The killSessions operation ignores sessions that have transactions in prepared state. See Behavior for details. |
Comportamento
Identificação da sessão
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.
Operações em andamento
A eliminação de uma sessão elimina as operações em andamento na sessão e fecha os cursores abertos associados a essas operações.
Disponibilidade de sessão eliminada
A sessão eliminada ainda pode estar listada como uma sessão atual e operações futuras podem usar a sessão eliminada. Para visualizar sessões existentes, consulte operação $listSessions ou $listLocalSessions .
Sessões com transação no estado preparado
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.
Exemplo
A operação a seguir finaliza a sessão especificada para o usuário:
db.runCommand( { killSessions: [ { id: UUID("f9b3d8d9-9496-4fff-868f-04a6196fc58a") } ] } )