定義
killSessionsThe
killSessionscommand 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.
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]
既存のセッションを表示
既存のセッションを表示するには、 $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") } ] } )
Tip