Docs 菜单

commitReshardCollection

commitReshardCollection

版本 5.0 中的新增功能

在重新分片操作期间,MongoDB 不会阻止写入,直到完成重新分片操作的估计持续时间低于两秒

If the current estimate is above two seconds but the time frame is acceptable to you, you can finish resharding faster. The commitReshardCollection command blocks writes early and forces the resharding operation to complete.

提示

mongosh 中,该命令也可通过 sh.commitReshardCollection() 辅助方法运行。

辅助方法对 mongosh 用户来说很方便,但它们返回的信息级别可能与数据库命令不同。如果不追求方便或需要额外的返回字段,请使用数据库命令。

此命令可用于以下环境中托管的部署:

注意

所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令

该命令具有以下语法:

db.adminCommand(
{
commitReshardCollection: "<database>.<collection>"
}
)

The mongosh provides a wrapper method sh.commitReshardCollection().

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

db.adminCommand({
commitReshardCollection: "sales.orders"
})

另请参阅: