定義
killAllSessionsByPatternThe
killAllSessionsByPatterncommand kills all sessions that match any of the specified patterns. [1]
構文
このコマンドの構文は、次のとおりです。
db.runCommand( { killAllSessionsByPattern: [ <pattern>, ... ] } )
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- 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 のバージョン
コマンドフィールド
このコマンドは、一致するパターンを指定するドキュメントの配列を受け取ります。
パターン | 説明 |
|---|---|
| 強制終了するセッション ID の UUID 部分を指定します。 |
| 強制終了するセッションの所有者のハッシュを指定します。 |
| Specifies the owners of the sessions to kill. Requires additional privileges. See Access Control. |
| Specifies the roles assigned to the owners of the sessions to kill. Requires additional privileges. See Access Control. |
Specify an empty array to kill all sessions. [1]
既存のセッションを表示するには、 $listSessions操作 または$listLocalSessionsを参照してください。
| [1] | (1, 2) The killAllSessionsByPattern operation ignores sessions that have transactions in prepared state. See Behavior for details. |
動作
進行中の操作
セッションを強制終了すると、セッション内で進行中の操作がすべて終了され、これらの操作に関連付けられている開いているカーソルが閉じられます。
強制終了されたセッションの可用性
強制終了されたセッションは引き続き現在のセッションとして表示され、今後の操作では強制終了されたセッションが使用される可能性があります。 既存のセッションを表示するには、 $listSessions操作 または$listLocalSessionsを参照してください。
トランザクションが準備済み状態のセッション
The killAllSessionsByPattern 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.
アクセス制御
If the deployment enforces authentication/authorization, you must have the killAnySession privilege action to run the killAllSessionsByPattern command.
usersまたはrolesを含むパターンでは、クラスター リソースに対してimpersonateアクションを許可する特権も必要です。
注意
ユーザーは、 killAnySession特権アクションがなくても自分のセッションを強制終了できます。
例
すべてのセッションを強制終了
次の操作は、すべてのセッションを強制終了します。
db.runCommand( { killAllSessionsByPattern: [ ] } )
特定のユーザーのすべてのセッションを強制終了
次の操作では、指定されたuidと指定されたロールを持つ所有者を持つすべてのセッションが強制終了されます。
db.runCommand( { killAllSessionsByPattern: [ { "uid" : BinData(0,"oBRA45vMY78p1tv6kChjQPTdYsnCHi/kA/fFMZTIV1o=") }, { roles: [ { role: "readWrite", db: "test" } ] } ] } )