Docs HomeMongoDB Manual

sh.commitReshardCollection()

On this page本页内容

Definition定义

sh.commitReshardCollection(namespace)

New in version 5.0. 5.0版新增。

During a resharding operation, MongoDB does not block writes until the estimated duration to complete the resharding operation is below two seconds.在重新发布操作期间,MongoDB不会阻止写入,直到估计完成重新发布操作的持续时间低于两秒。

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.sh.commitReshardCollection()方法会提前阻止写入并强制完成重新处理操作。

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

Syntax语法

The sh.commitReshardCollection() method has the following syntax:sh.commitReshardCollection()方法具有以下语法:

sh.commitReshardCollection( <namespace> )

Parameter参数

The sh.commitReshardCollection() method takes the following parameter:<sh.commitReshardCollection()方法采用以下参数:

Parameter参数Type类型Description描述
namespaceStringThe name of the collection to shard in the form "<database>.<collection>". 要分片的集合的名称,格式为"<database>.<collection>"

Example实例

Commit a Resharding Operation提交重新硬化操作

The following command forces the resharding operation on the sales.orders to block writes and complete:以下命令强制对sales.orders执行重新分片操作以阻止写入并完成:

sh.commitReshardCollection("sales.orders")
Tip

See also: 另请参阅:

Reshard a Collection