Docs Menu
Docs Home
/
MongoDB Manual
/ / /

sh.commitReshardCollection()

On this page

  • Definition
  • Syntax
  • Example
sh.commitReshardCollection(namespace)

New in version 5.0.

During a resharding operation, MongoDB does not block writes until the estimated duration to complete the resharding operation is below two seconds.

If the current estimate is above two seconds but the time frame is acceptable to you, you can finish resharding faster. The sh.commitReshardCollection() method 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.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

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

See also:

Back

sh.checkMetadataConsistency()