Docs Menu
Docs Home
/ /

sh.commitReshardCollection() (mongosh method)

sh.commitReshardCollection(namespace)

New in version 5.0.

sh.commitReshardCollection() blocks writes early and forces resharding operations to complete.

During a resharding operation, MongoDB does not block writes until the estimated duration to complete the resharding operation is below a certain value. In MongoDB 8.0.12 or earlier, this value is two seconds. In MongoDB 8.0.13 or later, this value is 500 milliseconds.

If the current estimated duration is above the threshold but the time frame is acceptable to you, you can finish resharding faster by calling sh.commitReshardCollection(). This blocks writes early and forces the resharding operation to complete.

Important

mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the commitReshardCollection command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

This method is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Important

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

The sh.commitReshardCollection() method has the following syntax:

sh.commitReshardCollection( <namespace> )

The sh.commitReshardCollection() method takes the following parameter:

Parameter
Type
Description

String

The name of the collection to shard in the form "<database>.<collection>".

The following command forces the resharding operation on the sales.orders to block writes and complete:

sh.commitReshardCollection("sales.orders")

Tip

Back

sh.checkMetadataConsistency

On this page