对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

sh.commitReshardCollection()(mongosh方法)

sh.commitReshardCollection(namespace)

版本 5.0 中的新增功能。

sh.commitReshardCollection() 阻止提前写入并强制完成重新分片操作。

在重新分片操作期间, MongoDB不会区块写入,直到完成重新分片操作的估计持续时间低于特定值。在MongoDB 8.0.12 或更早版本中,该值为两秒。在MongoDB 8.0.13 或更高版本中,该值为 500 毫秒。

如果当前估计的持续时间高于阈值但您可以接受时间范围,则可以通过调用 sh.commitReshardCollection() 更快地完成重新分片。这会阻止提前写入并强制完成重新分片操作。

重要

mongosh 方法

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

有关数据库命令,请参阅 commitReshardCollection 命令。

如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

重要

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

The sh.commitReshardCollection() method has the following syntax:

sh.commitReshardCollection( <namespace> )

The sh.commitReshardCollection() method takes the following parameter:

Parameter
类型
说明

字符串

要分片的集合名称,格式为"<database>.<collection>" 。

以下命令强制sales.orders上的重新分片操作以阻止写入并完成:

sh.commitReshardCollection("sales.orders")
给本页内容打分