Docs Menu
Docs Home
/
MongoDB Manual
/ / /

Stop Moving a Collection

On this page

  • About this Task
  • Access Control
  • Steps
  • Learn More

You can stop moving an unsharded collection by using the abortMoveCollection command.

To stop an in-progress moveCollection operation, run the abortMoveCollection command on the admin database.

If your deployment has access control enabled, the enableSharding role allows you to run the abortMoveCollection command.

1

To stop moving a collection, run the abortMoveCollection command. The following example stops the in-progress move of the app.inventory collection from shard01 to shard02.

db.adminCommand( {
abortMoveCollection: "app.inventory"
} )

After you run the abortMoveCollection command, the command output returns ok: 1 and resembles the following:

{
ok: 1,
'$clusterTime': {
clusterTime: Timestamp( { t: 1726524884, i: 28 } ),
signature: {
hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0),
keyId: Long('0')
}
},
operationTime: Timestamp({ t: 1726524884, i: 28 })
}
2

To confirm the collection wasn't moved to the new shard, use the $collStats pipeline stage.

The following example shows how to confirm that the app.inventory collection remains on the same shard:

db.inventory.aggregate( [
{ $collStats: {} },
{ $project: { "shard": 1 } }
] )

This pipeline stage has output similar to the following:

[ { shard: 'shard01' } ]

Back

Multi-tenant Architecture with Moveable Collections