定义
commitReshardCollection版本 5.0 中的新增功能。
commitReshardCollection阻止提前写入并强制完成重新分片操作。在重新分片操作期间, MongoDB不会区块写入,直到完成重新分片操作的估计持续时间低于特定值。在MongoDB 8.0.12 或更早版本中,该值为两秒。在MongoDB 8.0.13 或更高版本中,该值为 500 毫秒。
如果当前估计的持续时间高于阈值但您可以接受时间范围,则可以通过调用
commitReshardCollection更快地完成重新分片。这会阻止提前写入并强制完成重新分片操作。提示
In
mongosh, this command can also be run through thesh.commitReshardCollection()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
注意
所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { commitReshardCollection: "<database>.<collection>" } )
The mongosh provides a wrapper method sh.commitReshardCollection().
例子
提交重新分片操作
以下命令强制sales.orders上的重新分片操作以阻止写入并完成:
db.adminCommand({ commitReshardCollection: "sales.orders" })
提示