Definition定义
commitReshardCollectionNew 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如果当前的估计值超过两秒,但时间框架对您来说是可以接受的,您可以更快地完成换牌。commitReshardCollectioncommand blocks writes early and forces the resharding operation to complete.commitReshardCollection命令阻止早期写入并强制完成重新标记操作。Tip
In在mongosh, this command can also be run through thesh.commitReshardCollection()helper method.mongosh中,此命令也可以通过sh.commitReshardCollection()辅助方法运行。Helper methods are convenient for助手方法对mongoshusers, but they may not return the same level of information as database commands.mongosh用户来说很方便,但它们可能不会返回与数据库命令相同级别的信息。In cases where the convenience is not needed or the additional return fields are required, use the database command.如果不需要便利性或需要额外的返回字段,请使用database命令。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Note
This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.adminCommand(
{
commitReshardCollection: "<database>.<collection>"
}
)
The mongosh provides a wrapper method sh.commitReshardCollection().mongosh提供了一个包装器方法sh.commitReshardCollection()。
Example示例
Commit a Resharding Operation实施重新加固行动
The following command forces the resharding operation on the 以下命令强制对sales.orders to block writes and complete:sales.orders执行重新分片操作,以阻止写入并完成:
db.adminCommand({
commitReshardCollection: "sales.orders"
})