AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

killAllSessionsByPattern(データベースコマンド)

killAllSessionsByPattern

The killAllSessionsByPattern command 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 のバージョン

このコマンドは、一致するパターンを指定するドキュメントの配列を受け取ります。

パターン
説明

{ lsid: { id : <UUID> } }

強制終了するセッション ID の UUID 部分を指定します。

{ uid: <BinData> }

強制終了するセッションの所有者のハッシュを指定します。

{ users: [ { user: <user>, db: <dbname> }, ... ] }

Specifies the owners of the sessions to kill. Requires additional privileges. See Access Control.

{ roles: [ { role: <role>, db: <dbname> }, ... ] }

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" } ] }
] } )