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:用于云中 MongoDB 部署的完全托管服务
注意
所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
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" })
另请参阅: