killAllSessionsByPattern

Definition

  • killAllSessionsByPattern

New in version 3.6.

The killAllSessionsByPattern command kills all sessionsthat match any of the specified patterns:

Note

Killing a session kills any in-progress operations in thesession, and closes any open cursors associated with theseoperations. The killed session may still be listed as acurrent session, and future operations may use the killedsession.

  1. { killAllSessionsByPattern: [ <pattern>, ... ] }

The command takes an array of documents that specify the patterns tomatch:

PatternDescription{ lsid: { id : <UUID> } }Specify the UUID portion of the session id to kill.{ uid: <BinData> }Specifies the hash of the owner of the sessions to kill.{ users: [ { user: <user>, db: <dbname> }, … ] }Specifies the owners of the sessions to kill. Requiresadditional privileges. SeeAccess Control.{ roles: [ { role: <role>, db: <dbname> }, … ] }Specifies the roles assigned to the owners of the sessions tokill. Requires additional privileges. SeeAccess Control.

Specify an empty array to kill all sessions.

To run killAllSessionsByPattern, use the db.runCommand( { <command> } ) method.

To view existing sessions, see $listSessions operationor $listLocalSessions.

See also

killAllSessions

Access Control

If the deployment enforces authentication/authorization, you must havethe killAnySession to run thekillAllSessionsByPattern command.

For patterns that include users or roles, you must also haveprivileges that grant impersonate action on the clusterresource.

Note

Users can kill their own sessions even withoutkillAnySession privilege action.

Examples

Kill All Sessions

The following operation kills all sessions:

  1. db.runCommand( { killAllSessionsByPattern: [ ] } )

Kill All Sessions for Specific Users

The following operation kills all sessions that have the specifieduid and whose owner has the specified role:

  1. db.runCommand( { killAllSessionsByPattern: [
  2. { "uid" : BinData(0,"oBRA45vMY78p1tv6kChjQPTdYsnCHi/kA/fFMZTIV1o=") },
  3. { roles: [ { role: "readWrite", db: "test" } ] }
  4. ] } )